Some errors with recorders

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

Moderators: silvia, selimgunay, Moderators

Post Reply
talledo.diego
Posts: 20
Joined: Sat Jun 27, 2009 2:59 am
Location: IUAV - Venice

Some errors with recorders

Post by talledo.diego »

Dear frank,
I have a model 2d layered elements with an user-defined material.
I compiled with Visual Studio 2010. I'm using Windows 7 64 bit, but I compiled a 32 bit version of OpenSees.
The tcl file is following:

[code]
wipe
# Imposta il modello in 3 dimensioni con 6 gradi di libertà per nodo
# (3 traslazioni e 3 rotazioni)
model basic -ndm 3 -ndf 6

# MATERIAL
# In questa sezione inserire i materiali utilizzati.
# Materiale CONCRETE (nDMaterial)
set Ec 36000
set ni 0.15
#set ni 0.0
set fc1d -28.0
set fc1dOVERfc2d 1.2
set ElLimOVERfc1d 0.65
set f01d [expr $fc1d*$ElLimOVERfc1d]
set f02d [expr $f01d*$fc1dOVERfc2d]
set An 0.83
set Bn 1.32
set f0p 2.00
#set f0p 0.1
set Gf [expr (60.0/1000.0)]
set lc 50.0
set Ap [expr pow((($Gf*$Ec)/($lc*$f0p*$f0p)-(1.0/2.0)),-1)]
#set Ap 0.1
set beta 0.3
nDMaterial Concrete 1 $Ec $ni $f01d $f02d $f0p $beta $An $Bn $Ap
puts "nDMaterial Concrete 1 $Ec $ni $f01d $f02d $f0p $beta $An $Bn $Ap"
#nDMaterial ElasticIsotropic 1 $Ec $ni
#nDMaterial ElasticIsotropic 2 $Ec $ni
#puts "nDMaterial ElasticIsotropic 1 $Ec $ni"
# Materiale ACCIAIO (nDMaterial RLayer)
set Es 190000
set fy 360
nDMaterial RLayer 2 $Es 1.571 $fy 3500 3500 #lungo X glob (y loc)
nDMaterial RLayer 3 $Es 0.000 $fy 3500 3500 #lungo Y glob (x loc)
# Materiale PLATE FIBER
nDMaterial PlateFiber 4 1
nDMaterial PlateFiber 6 2 #lungo X glob (y loc)
nDMaterial PlateFiber 5 3 #lungo Y glob (x loc)
# nDMaterial PlaneStress 7 1
# puts "nDMaterial PlaneStress 7 1"

# SEZIONE: Section Plate Fiber
#sectag, thickness,numfibers,fibertagcls,fibertagReinf(i), pos(i), ro(i) [with i=1:4]
section MembranePlateFiberSectionCR 1 190 5 4 6 -0.75086 0.000 5 -0.74286 0.000 5 0.74286 0.000 6 0.75086 0.000
#section PlateFiber 1 4 190
section MembranePlateFiberSectionCR 2 190 5 4 6 -0.75086 0.064 5 -0.74286 0.000 5 0.74286 0.000 6 0.75086 0.064
#section MembranePlateFiberSectionCR 2 190 5 4 6 -0.75086 0.0 5 -0.74286 0.00 5 0.74286 0.00 6 0.75086 0.0
#section PlateFiber 2 5 190

#section ElasticMembranePlateSection 1 $Ec $ni 190 0.00025
#section ElasticMembranePlateSection 2 $Ec $ni 190 0.00025


# NODI: Coordinate dei nodi
source nodes.tcl

# ELEMENTI
source elements.tcl

# BOUNDARIES CONDITIONS
fix 12 0 1 1 1 1 0
fix 66 1 0 1 1 1 1
fix 67 1 0 1 1 1 1
fix 68 1 0 1 1 1 1
fix 69 1 0 1 1 1 1
fix 70 1 0 1 1 1 1

# Salvataggi
recorder Node -file "Nodo55_disp_2.out" -time -node 55 -dof 2 disp
#recorder Element -file stresses.out -time -eleRange 1 52 stresses
# recorder Element -file strains.out -time -eleRange 1 52 strains

# LOADS
pattern Plain 1 Linear {
load 55 0.0000 -1000.0000 0.0000 0.0000 0.0000 0.0000
}

#Solution algorithm
test NormDispIncr 1.0e-5 1000 0
numberer RCM
algorithm KrylovNewton
constraints Plain
system SparseGeneral -piv
analysis Static

set dU2 -0.025
integrator DisplacementControl 55 2 0.00
analyze 1
set dU1 -0.025
integrator DisplacementControl 55 2 $dU1
analyze 100
[/code]

if both element recorders (stresses and strains) are commented, all is ok and the code works well.
If I decomment element recorder for stresses the code runs well, but when I type exit in OpenSees, the program crashes.

After some debug I can say:
the problem is in function domain::clearAll:

in this section there is deleting of all recorders:

// remove the recorders
int i;
for (i=0; i<numRecorders; i++)
if (theRecorders[i] != 0)
delete theRecorders[i];

from the Call Stack I can see:
openSees.exe!Domani::clearAll() Line 813 + 0x3d byte
openSees.exe!ElementRecorder::'scalar deleting destructur'() + 0x2b bytes
openSees.exe!ElementRecorder::~ElementRecorder() Line 119 + 0x3d bytes
openSees.exe!ElementResponse::'scalar deleting destructor'() + 0x2b bytes
openSees.exe!ElementResponse::~ElementResponse() Line 78 + 0x8 bytes
openSees.exe!Response::~Response() Line 70 + 0xb bytes
openSees.exe!Information::~Information() Line 110 + 0x2e bytes
openSees.exe!Vector::'scalar deleting destructor'() + 0x2b bytes
openSees.exe!Vector::~Vector() Line 135 + 0x18 bytes
openSees.exe!operator delete(void * pUserData=0x37e0350) Line 52 + 0x51 bytes

when he tries to delete the last Recorder (the element recorder), he tries to delete the Element responses:

if (theResponses != 0) {
for (int i = 0; i < numEle; i++)
delete theResponses[i];
delete [] theResponses;
}

Then there is deleting of object Information, where the last function called is:

if (theVector != 0)
delete theVector;

which is:

if (sz != 0 && fromFree == 0)
delete [] theData;
// free((void *)theData);

this line (delete [] theData
makes the error in (dbgdel.cpp):

/* verify block type */
_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));


What can I search to find the error?
I'm not a C++ expert programmer. I'm new in C++ because I use to program in Visual Basic or Delphi.

Thank you for any information

Diego Talledo
Diego Alejandro Talledo
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

what does your setResponse method look like.
talledo.diego
Posts: 20
Joined: Sat Jun 27, 2009 2:59 am
Location: IUAV - Venice

Post by talledo.diego »

This is my setResponse code of ShellMITC4.cpp:

[code]
Response*
ShellMITC4::setResponse(const char **argv, int argc, OPS_Stream &output)
{
Response *theResponse = 0;

output.tag("ElementOutput");
output.attr("eleType", "ShellMITC4");
output.attr("eleTag",this->getTag());
int numNodes = this->getNumExternalNodes();
const ID &nodes = this->getExternalNodes();
static char nodeData[32];

for (int i=0; i<numNodes; i++) {
sprintf(nodeData,"node%d",i+1);
output.attr(nodeData,nodes(i));
}

if (strcmp(argv[0],"force") == 0 || strcmp(argv[0],"forces") == 0 ||
strcmp(argv[0],"globalForce") == 0 || strcmp(argv[0],"globalForces") == 0) {
const Vector &force = this->getResistingForce();
int size = force.Size();
for (int i=0; i<size; i++) {
sprintf(nodeData,"P%d",i+1);
output.tag("ResponseType",nodeData);
}
theResponse = new ElementResponse(this, 1, this->getResistingForce());
}

else if (strcmp(argv[0],"material") == 0 || strcmp(argv[0],"Material") == 0) {
if (argc < 2) {
opserr << "ShellMITC4::setResponse() - need to specify more data\n";
return 0;
}
int pointNum = atoi(argv[1]);
if (pointNum > 0 && pointNum <= 4) {

output.tag("GaussPoint");
output.attr("number",pointNum);
output.attr("eta",sg[pointNum-1]);
output.attr("neta",tg[pointNum-1]);

theResponse = materialPointers[pointNum-1]->setResponse(&argv[2], argc-2, output);

output.endTag();
}

} else if (strcmp(argv[0],"stresses") ==0) {

for (int i=0; i<4; i++) {
output.tag("GaussPoint");
output.attr("number",i+1);
output.attr("eta",sg[i]);
output.attr("neta",tg[i]);

output.tag("SectionForceDeformation");
output.attr("classType", materialPointers[i]->getClassTag());
output.attr("tag", materialPointers[i]->getTag());

output.tag("ResponseType","p11");
output.tag("ResponseType","p22");
output.tag("ResponseType","p1212");
output.tag("ResponseType","m11");
output.tag("ResponseType","m22");
output.tag("ResponseType","m12");
output.tag("ResponseType","q1");
output.tag("ResponseType","q2");

output.endTag(); // GaussPoint
output.endTag(); // NdMaterialOutput
}

theResponse = new ElementResponse(this, 2, Vector(32));
}

else if (strcmp(argv[0],"strains") ==0) {

for (int i=0; i<4; i++) {
output.tag("GaussPoint");
output.attr("number",i+1);
output.attr("eta",sg[i]);
output.attr("neta",tg[i]);

output.tag("SectionForceDeformation");
output.attr("classType", materialPointers[i]->getClassTag());
output.attr("tag", materialPointers[i]->getTag());

output.tag("ResponseType","eps11");
output.tag("ResponseType","eps22");
output.tag("ResponseType","gamma12");
output.tag("ResponseType","theta11");
output.tag("ResponseType","theta22");
output.tag("ResponseType","theta33");
output.tag("ResponseType","gamma13");
output.tag("ResponseType","gamma23");

output.endTag(); // GaussPoint
output.endTag(); // NdMaterialOutput
}

theResponse = new ElementResponse(this, 3, Vector(32));
}

output.endTag();
return theResponse;
}
[/code]

thank you for your attention!
Diego Alejandro Talledo
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

does it only happen with your material?
talledo.diego
Posts: 20
Joined: Sat Jun 27, 2009 2:59 am
Location: IUAV - Venice

Post by talledo.diego »

No, for example, I've done following model that use only nDMaterial Elastic and PlateFiber:

[code]
# Modello T9.tcl
# Trave senza armatura a taglio
# Tratta da esperimenti di Leonhardt e Walther

# Cancella tutte le variabili
wipe
# Imposta il modello in 3 dimensioni con 6 gradi di libertà per nodo
# (3 traslazioni e 3 rotazioni)
model basic -ndm 3 -ndf 6

# MATERIAL
# In questa sezione inserire i materiali utilizzati.
# Materiale CONCRETE

set Ec 36000
set ni 0.15


# Materiale PLATE FIBER
nDMaterial PlateFiber 4 1


# SEZIONE: Section Plate Fiber

section PlateFiber 1 4 190

section PlateFiber 2 4 190


# NODI: Coordinate dei nodi
source nodes.tcl

# ELEMENTI
source elements.tcl

# BOUNDARIES CONDITIONS
fix 12 0 1 1 1 1 0
fix 66 1 0 1 1 1 1
fix 67 1 0 1 1 1 1
fix 68 1 0 1 1 1 1
fix 69 1 0 1 1 1 1
fix 70 1 0 1 1 1 1

# Salvataggi
recorder Node -file "Nodo55_disp_2.out" -time -node 55 -dof 2 disp
recorder Element -file stresses.out -time -eleRange 1 52 stresses
recorder Element -file strains.out -time -eleRange 1 52 strains

# LOADS
pattern Plain 1 Linear {
load 55 0.0000 -1000.0000 0.0000 0.0000 0.0000 0.0000
}

#Solution algorithm
test NormDispIncr 1.0e-5 1000 0
numberer RCM
algorithm KrylovNewton
constraints Plain
system SparseGeneral -piv
analysis Static

set dU2 -0.025
integrator DisplacementControl 55 2 0.00
analyze 1
set dU1 -0.025
integrator DisplacementControl 55 2 $dU1
analyze 100
[/code]
Diego Alejandro Talledo
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

can you send me a small example in which this happens so i can debug it to find where the problem is.

f m c k e n n a ATTTT c e DOTTTTTT berkeley DOOOOT edu
talledo.diego
Posts: 20
Joined: Sat Jun 27, 2009 2:59 am
Location: IUAV - Venice

Re: Some errors with recorders

Post by talledo.diego »

Dear Dr. McKenna,

did you receive my mail with a sample code?
Were you able to reproduce the error?

Thank you very much

Diego Talledo
Last edited by talledo.diego on Sat Apr 16, 2011 2:39 pm, edited 1 time in total.
Diego Alejandro Talledo
Post Reply