dear fmk.access violation when read the position 0xcccccccc

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
fluozhen
Posts: 23
Joined: Thu May 07, 2009 7:33 pm
Location: nuaa

dear fmk.access violation when read the position 0xcccccccc

Post by fluozhen »

plz help me.
The visual studio C++ report "access violation occurs when read the position 0xcccccccc" when I run the code. there's a part of the codes where the mistake is I think. sorry for my English.
UniaxialMaterial *theMaterial1=new ElasticMaterial(3,E*A);
UniaxialMaterial *theMaterial2=new Steel01(2,130000,130000/0.65e-4,0.01,0.0,55.0,0.0,55.0);
[u][i]UniaxialMaterial **theMaterial=new UniaxialMaterial*[2];
theMaterial[0]=theMaterial1;
theMaterial[1]=theMaterial2;[/i][/u]
static int code[2]={1,2};//1-P,2_Mz
const ID thecode(code,2);

[b]SectionForceDeformation *agg=new SectionAggregator(1, 2,theMaterial, thecode);[/b]

CrdTransf2d *theTransf=new LinearCrdTransf2d(1);

ForceBeamColumn2d(int tag, int nodeI, int nodeJ, int numSections, SectionForceDeformation **sec,
//BeamIntegration &beamIntegr,CrdTransf2d &coordTransf, double rho = 0.0,int maxNumIters = 10, double tolerance = 1.0e-12);

BeamIntegration *BeamIntegr=new HingeEndpointBeamIntegration();

[u][i]Element *thecolumn1=new ForceBeamColumn2d(1,1,2,2,&agg,*BeamIntegr,*theTransf,0.0,10,1e-12);

Element *thecolumn2=new ForceBeamColumn2d(1,2,3,2,&agg,*BeamIntegr,*theTransf,0.0,10,1e-12);[/i][/u]
theDomain->addElement(thecolumn1);
theDomain->addElement(thecolumn2);
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

what line does the error happen .. and do you not have access to a debugger! .. if you are planning on writing code you need to have access to a debugger and you need to know how to use it!
fluozhen
Posts: 23
Joined: Thu May 07, 2009 7:33 pm
Location: nuaa

dear fmk.

Post by fluozhen »

[quote="fmk"]what line does the error happen .. and do you not have access to a debugger! .. if you are planning on writing code you need to have access to a debugger and you need to know how to use it![/quote]

dear fmk,thank u for ur reply. I debug the code and the mistake happened on this place:

ForceBeamColumn2d::setSectionPointers(int numSec, SectionForceDeformation **secPtrs)
{
if (numSec > maxNumSections) {
opserr << "Error: ForceBeamColumn2d::setSectionPointers -- max number of sections exceeded";
}

numSections = numSec;

if (secPtrs == 0) {
opserr << "Error: ForceBeamColumn2d::setSectionPointers -- invalid section pointer";
}

sections = new SectionForceDeformation *[numSections];
if (sections == 0) {
opserr << "Error: ForceBeamColumn2d::setSectionPointers -- could not allocate section pointers";
}

for (int i = 0; i < numSections; i++) {

if (secPtrs[i] == 0) {
opserr << "Error: ForceBeamColumn2d::setSectionPointers -- null section pointer " << i << endln;
}



[size=18]sections[i] = secPtrs[i]->getCopy();//[color=red]it happens on this line when i=1.[/color][/size]



if (sections[i] == 0) {
opserr << "Error: ForceBeamColumn2d::setSectionPointers -- could not create copy of section " << i << endln;
}
}
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

the debugger should be able to tell you the line nu .. if not do some manual debugging by putting stuff like opserr << "HERE -1\n" in the source code to see what the offending line of code is.
fluozhen
Posts: 23
Joined: Thu May 07, 2009 7:33 pm
Location: nuaa

To fmk

Post by fluozhen »

[quote="fmk"]the debugger should be able to tell you the line nu .. if not do some manual debugging by putting stuff like opserr << "HERE -1\n" in the source code to see what the offending line of code is.[/quote]

Dear fmk, Thank u for your patience and guidance, it is probably a very simple question, but I really sorry about that I do not understand what does the "opserr << "HERE -1\n" means. I debug my code, but it's interrupted on this line :sections[i] = secPtrs[i]->getCopy();,which is the function of "ForceBeamColumn2d::setSectionPointers(int numSec, SectionForceDeformation **secPtrs)", I do not know what points to the problem, please help me to solve it.
Many thanks and sorry for my English.
here is my poor code, plz correct me.

#include <stdlib.h>
#include <iostream>
#include <OPS_Globals.h>
#include <StandardStream.h>
#include <bool.h>
#include <ArrayOfTaggedObjects.h>
#include <MovableObject.h>
#include <math.h>
#include <string.h>
#include <map>
#include <File.h>
#include <float.h>
#include <fstream>
#include <DataFileStream.h>
//domain
#include <Domain.h>
#include <Element.h>
#include <ElasticBeam2d.h>
#include <ForceBeamColumn2d.h>
#include <Node.h>
#include <Material.h>
#include <ID.h>
#include <BeamIntegration.h>
#include <ElasticMaterial.h>
#include <SP_Constraint.h>
#include <LoadPattern.h>
#include <LinearSeries.h>
#include <NodalLoad.h>
#include <Vector.h>
#include <Matrix.h>
#include <Concrete01.h>
#include <Steel01.h>
#include <DispBeamColumn2d.h>
#include <SectionForceDeformation.h>
#include <Response.h>
#include <CrdTransf2d.h>
#include <LinearCrdTransf2d.h>
#include <Renderer.h>
#include <Information.h>
#include <Parameter.h>
#include <Channel.h>
#include <FEM_ObjectBroker.h>
#include <ElementResponse.h>
#include <ElementalLoad.h>
#include <SectionIntegration.h>
#include <FiberSection2d.h>
#include <UniaxialMaterial.h>
#include <Cell.h>
#include <FiberSectionRepr.h>
#include <UniaxialFiber2d.h>
#include <Patch.h>
#include <QuadPatch.h>
#include <QuadCell.h>
#include <ReinfLayer.h>
#include <ReinfBar.h>
#include <StraightReinfLayer.h>
#include <HingeEndpointBeamIntegration.h>
#include <FE_Datastore.h>
#include <NodeRecorder.h>
#include <NodeIter.h>
#include <Recorder.h>
#include <classTags.h>
#include <SectionAggregator.h>
#include <PathSeries.h>
#include <UniformExcitation.h>
#include <GroundMotionRecord.h>
//分析类
#include <StandardEigenAlgo.h>

#include <EigenAlgorithm.h>
#include <EigenAnalysis.h>
#include <EigenIntegrator.h>
#include <EigenSOE.h>
#include <FullGenEigenSolver.h>
#include <EigenSolver.h>
#include <FullGenEigenSOE.h>
#include <Analysis.h>
#include <StaticIntegrator.h>
#include <TransientIntegrator.h>
#include <DisplacementControl.h>
#include <LoadControl.h>
#include <StaticAnalysis.h>
#include <TransientAnalysis.h>
#include <DirectIntegrationAnalysis.h>
#include <AnalysisModel.h>
#include <Linear.h>
#include <PlainHandler.h>
#include <DOF_Numberer.h>
#include <PlainNumberer.h>
#include <RCM.h>
#include <EquiSolnAlgo.h>
#include <Vector.h>
#include <NewtonRaphson.h>
#include <Newmark.h>
#include <LinearSOESolver.h>
#include <ConvergenceTest.h>
#include <CTestEnergyIncr.h>
#include <CTestNormDispIncr.h>
#include <BandGenLinSOE.h>
#include <BandGenLinSolver.h>
#include <BandGenLinLapackSolver.h>
#include <f2c.h>

StandardStream sserr;
OPS_Stream *opserrPtr = &sserr;

double ops_Dt = 0;
Domain *ops_TheActiveDomain = 0;
Element *ops_TheActiveElement = 0;

int main(int argc, char **argv)
{

Domain *theDomain = new Domain();

double Lcol=432.0, g=384.6;
Node *node1=new Node(1,3,0.0,0.0);
Node *node2 = new Node(2, 3, 0.0,Lcol/2);
Node *node3 = new Node(3, 3, 0.0,Lcol);
theDomain->addNode(node1);
theDomain->addNode(node2);
theDomain->addNode(node3);
Matrix mass(3,3);
mass(0,0)=2000/g;
mass(0,1)=0;
mass(0,2)=0;
mass(1,0)=0;
mass(1,1)=1e-6;
mass(1,2)=0;
mass(2,2)=0;
mass(2,1)=0;
mass(2,0)=0;
node2->setMass(mass);
node3->setMass(mass);

double A=60*60*1000, I=60*60^3/12;
double fc=-4,E=57*sqrt(-fc*1000); //compression "-"
UniaxialMaterial *theMaterial1=new ElasticMaterial(3,E*A);
UniaxialMaterial *theMaterial2=new Steel01(2,130000,130000/0.65e-4,0.01,0.0,55.0,0.0,55.0);
UniaxialMaterial **theMaterial=new UniaxialMaterial*[2];
theMaterial[0]=theMaterial1;
theMaterial[1]=theMaterial2;
static int code[2]={1,2};//1-P,2_Mz at SectionForceDeformation.h
const ID thecode(code,2);

SectionForceDeformation *agg=new SectionAggregator(1, 2,theMaterial, thecode);

CrdTransf2d *theTransf=new LinearCrdTransf2d(1);

// ForceBeamColumn2d(int tag, int nodeI, int nodeJ, int numSections, SectionForceDeformation **sec,
//BeamIntegration &beamIntegr,CrdTransf2d &coordTransf, double rho = 0.0,int maxNumIters = 10, double tolerance = 1.0e-12);

BeamIntegration *BeamIntegr=new HingeEndpointBeamIntegration();
Element *thecolumn1=new ForceBeamColumn2d(1,1,2,2,&agg,*BeamIntegr,*theTransf,0.0,10,1e-12);
Element *thecolumn2=new ForceBeamColumn2d(1,2,3,2,&agg,*BeamIntegr,*theTransf,0.0,10,1e-12);
theDomain->addElement(thecolumn1);
theDomain->addElement(thecolumn2);

//SP_Constraint(tag, nodeTag, dofID, value)
SP_Constraint *sp1 = new SP_Constraint(1, 1, 0, 1.0);
SP_Constraint *sp2 = new SP_Constraint(2, 1, 1, 1.0);
SP_Constraint *sp3 = new SP_Constraint(3, 1, 2, 1.0);
theDomain->addSP_Constraint(sp1);
theDomain->addSP_Constraint(sp2);
theDomain->addSP_Constraint(sp3);


// LinearSeries(double cFactor = 1.0);
TimeSeries *series=new LinearSeries();

LoadPattern *theLoadPattern = new LoadPattern(1);
theLoadPattern->setTimeSeries(series);
theDomain->addLoadPattern(theLoadPattern);
// NodalLoad(tag, nodeID, Vector &)
double load1[3]={0.0,-2000.0,0.0};
const Vector *theLoadValues1=new Vector(load1,3);

NodalLoad *theLoad1 = new NodalLoad(1, 2, *theLoadValues1);
NodalLoad *theLoad2 = new NodalLoad(2, 3, *theLoadValues1);

theDomain->addNodalLoad(theLoad1, 1);
theDomain->addNodalLoad(theLoad2, 1);


AnalysisModel *theModel = new AnalysisModel();
ConvergenceTest *test=new CTestNormDispIncr(10e-8,6,0);
EquiSolnAlgo *theSolnAlgo = new NewtonRaphson(*test);
StaticIntegrator *theIntegrator = new LoadControl(0.1,10,0.1,1.0);
ConstraintHandler *theHandler = new PlainHandler();
DOF_Numberer *theNumberer = new PlainNumberer();
BandGenLinSolver *theSolver = new BandGenLinLapackSolver();
LinearSOE *theSOE = new BandGenLinSOE(*theSolver);

StaticAnalysis theAnalysis(*theDomain, theHandler,*theNumberer,*theModel,*theSolnAlgo,*theSOE,*theIntegrator,test);
int numSteps = 10;
theAnalysis.analyze(numSteps);
opserr << *theDomain;

theDomain->setLoadConstant();


double dt=0.01, Tmax=10;
const char *filename="BM68elc.acc";
TimeSeries *theaccelSeries = new PathSeries(filename,0.01,1);
GroundMotion *theMotion=new GroundMotionRecord(filename, 1.0,1.0,0.01);
//GroundMotion(0,0,theaccelSeries);
//UniformExcitation(GroundMotion &theMotion,int dof, int tag, double vel0 = 0.0);

LoadPattern *theLoadPattern1 = new UniformExcitation(*theMotion,1, 400,0.0);
theLoadPattern1->setTimeSeries(theaccelSeries);
theDomain->addLoadPattern(theLoadPattern1);


//DisplacementControl(int node, int dof, double increment, Domain *domain,int numIncr,double min, double max)
AnalysisModel *theModel1 = new AnalysisModel();
ConvergenceTest *test1=new CTestEnergyIncr(10e-8,6,0);
EquiSolnAlgo *theSolnAlgo1 = new NewtonRaphson(*test1);
ConstraintHandler *theHandler1 = new PlainHandler();
DOF_Numberer *theNumberer1 = new PlainNumberer();
BandGenLinSolver *theSolver1 = new BandGenLinLapackSolver();
BandGenLinSOE *theSOE1 = new BandGenLinSOE(*theSolver1);

//EigenAnalysis(Domain &theDomain,ConstraintHandler &theHandler, DOF_Numberer &theNumberer,AnalysisModel &theModel,
//EigenAlgorithm &theAlgo, EigenSOE &theSOE, EigenIntegrator &theIntegrator);

FullGenEigenSolver *eigen_theSolver = new FullGenEigenSolver();
EigenAlgorithm *eigen_theSolnAlgo = new StandardEigenAlgo();
FullGenEigenSOE *eigen_theSOE=new FullGenEigenSOE (*eigen_theSolver,*theModel);
EigenIntegrator *eigen_theIntegrator = new EigenIntegrator();
EigenAnalysis eigen_Analysis(*theDomain,*theHandler,*theNumberer,
* theModel,*eigen_theSolnAlgo,*eigen_theSOE,*eigen_theIntegrator);
int lamda=eigen_Analysis.analyze(1);

//Newmark(double gamma, double beta, double alphaM, double betaK, double betaKi, double betaKc, bool disp = true);
TransientIntegrator *theIntegrator1 = new Newmark(0.5, 0.25, 0.0, 0.0,0.0, 2*0.02/sqrt((double)lamda), 1);
DirectIntegrationAnalysis theAnalysis1(*theDomain,*theHandler1 ,*theNumberer1, *theModel1,*theSolnAlgo1,*theSOE1,*theIntegrator1,test1);
int numSteps2 =1000;
theAnalysis1.analyze(numSteps2,0.01);
opserr << *theDomain;
exit (0);
}
Post Reply