[Trilinos-Users] Memory allocation error
Daniel Kanewske
danielkanewske at gmail.com
Thu Apr 11 08:45:16 MDT 2013
As things stand if I use Nb_Ele_No = 34;, then Nb_Edg.Size(Nb_Ele_No);
then the memory allocation error occurs after Mesh2dPreBndry. If I use 35
then Nb_Edg.Size(Nb_Ele_No); causes the malloc error. If I
assign Nb_Edg.Size(Nb_Ele_No); in main then Nb_Ele.Shape(Nb_Ele_No,2);
crashes. If I pull Nb_Ele.Shape(Nb_Ele_No,2); into main,
then Mesh2dPreBndry crashes before std::cout << "In PreMesh" << endl;.
All with malloc errors. This malloc error is propagating back up the
program as I remove lines of execution from Mesh2dPreBndry and place them
in main. If I switch the order call **Mesh2dPreBndry before Mesh2dVelBndry
then both programs execute and I get a malloc error later in the program.
This is all very strange.
** **
I have checked again and again. Everything seems to be declared correctly.
I can't figure it out. Any help would be appreciated.****
** **
Thx,****
Dan****
** **
// Main program for my 2D FEM model of viscco-elastic fluid flow.****
** **
#include "Epetra_ConfigDefs.h"****
#ifdef HAVE_MPI****
#include "mpi.h"****
#include "Epetra_MpiComm.h"****
#else****
#include "Epetra_SerialComm.h"****
#endif****
** **
#include "Epetra_SerialDenseVector.h"****
#include "Epetra_IntSerialDenseVector.h"****
#include "Epetra_SerialDenseMatrix.h"****
#include "Epetra_IntSerialDenseMatrix.h"****
#include "Epetra_SerialDenseSolver.h"****
** **
#include <fstream>****
#include "Mesh2d.h"****
#include "Mesh2dPreBndry.h"****
#include "Mesh2dVelBndry.h"****
#include "Boundary2d.h"****
#include "Assembly.h"****
#include "QuadPtWt.h"****
#include "InitialVel.h"****
#include "InitialStr.h"****
#include "ElementNeigh.h"****
#include "Conformation.h"****
#include "DepartureInfo.h"****
** **
typedef Epetra_SerialDenseMatrix E_SDM;****
typedef Epetra_IntSerialDenseMatrix E_ISDM;****
typedef Epetra_SerialDenseVector E_SDV;****
typedef Epetra_IntSerialDenseVector E_ISDV;****
** **
//Constants****
const int NX = 10; // Number of element
intervals in the horizontal direction****
const int NY = 10;****
const int NGP = 4; // Number of Gauss points
in numerical quadrature, used on the boundary****
const int N_TRI_QUAD = 4; // Number of Gauss points in
numerical quadrature, used in the element****
const int MAX_TIME_STEP_NUM = 100; // Maximum number of time interations***
*
const int VEL_FLAG = 2; // Program flags****
const int PRE_FLAG = 1;****
const double XL = 0.0; // coordinate of
left boundary element****
const double XR = 1.0; // coordinate of
right boundary element****
const double YB = 0.0; // Coordinate of
the bottom boundary of the domain.****
const double YT = 1.0; // Coordinate of
the top boundary of the domain.****
const double RE = 1.0; // Reynold's
Number ****
const double NEW_VIS = 1.0; // Newtonian Viscosity
****
const double TIMESTEP = 1.0; // Time
Step ****
const double TOL = 0.00000000001; // Is this good?****
const double ALPHA = 1.0; ****
const double BETA = 1.0; ****
** **
int main(int argc, char *argv[])****
{****
#ifdef HAVE_MPI****
MPI_Init(&argc, &argv);****
Epetra_MpiComm Comm(MPI_COMM_WORLD);****
#else****
Epetra_SerialComm Comm;****
#endif****
****
// variable decalrations****
// Velocity Related****
// Velocity is NNMX2, Depart_Vel is Gaus_Pt_NumX2****
E_SDM Vel, Vel_New, Vel_Glxy, Depart_Vel;****
E_ISDM Vel_Nod, Vel_Nb_Ele;****
E_SDV Vel_Norm;****
E_ISDV Vel_Eb_Node, Vel_Nb_Edg;****
int Vel_Npe, Vel_Nb_Ele_No, Vel_Eb_Node_No, Vel_Nnm;****
double Vel_Tol;****
****
// Presure Related****
E_SDM Pre_Glxy;****
E_ISDM Pre_Nod, Pre_Nb_Ele;****
E_ISDV Pre_Eb_Node, Pre_Nb_Edg;****
E_SDV Pre, Pre_Norm, Pre_New;****
int Pre_Npe, Pre_Nb_Ele_No, Pre_Eb_Node_No, Pre_Nnm;****
double Pre_Tol;****
****
// There are no essential pressure B.C.s but so that I do not have to
write a second Boundary2d program****
// I will still need these variables as input parameters.****
Pre_Eb_Node.Size(1);****
Pre_Eb_Node(0) = 0;****
Pre_Eb_Node_No = 0;****
****
// Stress Related****
// Stess is NNMX3, Depart_Str is Gaus_Pt_NumX3****
E_SDM Str, Str_New, Depart_Str;****
E_SDV c, F2;****
****
// Other****
E_SDM GAUSPT, GAUSWT, Tri_Quad_Pt, A, AC, D;****
E_ISDM Ele_Neigh;****
E_SDV F1, FC, x, Tri_Quad_Wt;****
int Nem, L, n, Gauss_Pt_Num; // L, n are counters****
double dx, dy;****
****
...****
****
Nem = 2*NX*NY; // Number of triangular nodes in the mesh.****
****
// Step sizes****
dx = (XR - XL) / NX; // mesh size in the x direction****
dy = (YT - YB) / NY; // mesh size in the y direction****
****
// preprocessor, generate mesh and connectivity matrix****
Mesh2d(dx, ****
dy,****
XL,****
XR,****
YB, ****
YT, ****
NX, ****
NY, ****
VEL_FLAG, ****
Nem, ****
Vel_Nnm, ****
Vel_Npe, ****
Vel_Glxy, ****
Vel_Nod);****
****
Mesh2d(dx, ****
dy, ****
XL, ****
XR, ****
YB, ****
YT, ****
NX, ****
NY, ****
PRE_FLAG, ****
Nem, ****
Pre_Nnm, ****
Pre_Npe, ****
Pre_Glxy, ****
Pre_Nod);****
****
// Solution vectors****
x.Size(2*Vel_Nnm + Pre_Nnm);****
c.Size(4*Pre_Nnm);****
****
// Velocity, Pressure and Stress Data****
Vel.Shape(Vel_Nnm,2);****
Pre.Size(Pre_Nnm);****
Str.Shape(Pre_Nnm,3); // Only Pre_Nnm, 3 because the stress is symmetric**
**
****
std::cout << "Here before MeshVel" << endl;****
****
Mesh2dVelBndry(NX, ****
NY,****
Vel_Nb_Ele_No, ****
Vel_Nb_Ele, ****
Vel_Nb_Edg, ****
Vel_Eb_Node_No, ****
Vel_Eb_Node);****
****
std::cout << "Here after MeshVel" << endl;****
****
// Pre_Nb_Ele.Shape(2 * (NX + NY),2);****
// Pre_Nb_Edg.Size(2 * (NX + NY));****
****
Mesh2dPreBndry(NX, ****
NY,****
Pre_Nb_Ele_No, ****
Pre_Nb_Ele, ****
Pre_Nb_Edg);****
** **
std::cout << "Here after MeshPre" << endl;****
****
...****
****
return 0;****
}****
** **
// Pressure Boundary Mesh for parallel plate problem****
// Nb_Ele_No: number of elements with Natural BC****
// Nb_Ele: element list with natural BC, array of size Nb_Ele_Nox2**
**
// Nb_Ele(I,1): element index of I-th Natural boundary element****
// Nb_Ele(I,2): number of natural boundary condition edges with
NBC in I-th boundary element****
// Nb_Edg: local edge number of the boundary element, array of size*
***
// Nb_Ele_Nox2, NB_EDG(I,j) = local edge number of j-th****
// boundary edge in I-the boundary element, 1 <= j <=
NBELE(I,2)****
** **
// First the left side, then bottom plate, then the right side, and then
the top plate.****
** **
#include <cmath>****
#include "Mesh2dPreBndry.h"****
#include "Epetra_IntSerialDenseMatrix.h"****
#include "Epetra_IntSerialDenseVector.h"****
** **
typedef Epetra_IntSerialDenseMatrix E_ISDM;****
typedef Epetra_IntSerialDenseVector E_ISDV;****
** **
void Mesh2dPreBndry(int NX, ****
int NY,****
int & Nb_Ele_No, ****
E_ISDM & Nb_Ele, ****
E_ISDV & Nb_Edg){****
****
std::cout << "In PreMesh" << endl;****
****
// natural boundary condition****
Nb_Ele_No = 34; // 35 crashes // 2 * (NX + NY);****
std::cout << "Before Shape" << endl;****
Nb_Ele.Shape(Nb_Ele_No,2);****
std::cout << "After Shape" << endl;****
Nb_Edg.Size(Nb_Ele_No);****
** **
std::cout << "After Size" << endl;****
****
...****
****
}****
** **
// Velocity Boundary Mesh for parallel plate problem****
// Nb_Ele_No: number of elements with Natural BC****
// Nb_Ele: element list with natural BC, array of size Nb_Ele_Nox2**
**
// Nb_Ele(I,1): element index of I-th Natural boundary element****
// Nb_Ele(I,2): number of natural boundary condition edges with
NBC in I-th boundary element****
// Nb_Edg: local edge number of the boundary element, array of size*
***
// Nb_Ele_Nox2, NB_EDG(I,j) = local edge number of j-th****
// boundary edge in I-the boundary element, 1 <= j <=
NBELE(I,2)****
// Eb_Node_No: number of nodes with Essential BCs****
// Eb_Node: global node number of EBC node, array of size
EB_NODE_NOx1****
** **
// First the left side, then bottom plate, then the right side, and then
the top plate.****
** **
#include "Mesh2dVelBndry.h"****
#include "Epetra_IntSerialDenseMatrix.h"****
#include "Epetra_IntSerialDenseVector.h"****
** **
typedef Epetra_IntSerialDenseMatrix E_ISDM;****
typedef Epetra_IntSerialDenseVector E_ISDV;****
** **
void Mesh2dVelBndry(int NX, ****
int NY,****
int & Nb_Ele_No, ****
E_ISDM & Nb_Ele, ****
E_ISDV & Nb_Edg, ****
int & Eb_Node_No, ****
E_ISDV & Eb_Node) {****
****
// natural boundary condition****
Nb_Ele_No = 2*(NX+NY);****
Nb_Ele.Shape(Nb_Ele_No,2);****
Nb_Edg.Size(Nb_Ele_No);****
****
for(int i = 0; i <= Nb_Ele_No - 1; i++)****
{****
Nb_Ele(i,0) = 0;****
Nb_Ele(i,1) = 0;****
****
Nb_Edg(i) = 0;****
}****
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20130411/63719af8/attachment.html
More information about the Trilinos-Users
mailing list