New complex element

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

Moderators: silvia, selimgunay, Moderators

Post Reply
gst77
Posts: 18
Joined: Sat Nov 28, 2009 9:23 am
Location: UNCuyo

New complex element

Post by gst77 »

Dear Frank,
First of all, I'm not a Objet Oriented Programmer, so I'm writing my own element routine by myself, based on the examples in the source code and reading some books about OOP.
I'm trying to implement a new element with 7 sub elements. The first 6 subelements uses the material #1 and the last element use the material #2.
I wanted to know if this part of the code is correct or if there is a simpler way to do it.
Thank you very much for your time and patience.

Best regards,

Gonzalo


int matID1 = iData[13];
UniaxialMaterial *theMaterial = OPS_GetUniaxialMaterial(matID1);
int matID2 = iData[14];
UniaxialMaterial *theMaterial2 = OPS_GetUniaxialMaterial(matID2);

if (theMaterial == 0) {
opserr << "WARNING material with tag " << matID1 << "not found for element " << eleTag << endln;
return 0;
}
if (theMaterial2 == 0) {
opserr << "WARNING material with tag " << matID2 << "not found for element " << eleTag << endln;
return 0;
}

// now create the Panel and add it to the Domain

thePanel = new MasonPan(eleTag, iData[1], iData[2], iData[3], iData[4], iData[5], iData[6], iData[7], iData[8], iData[9], iData[10], iData[11], iData[12], *theMaterial, *theMaterial2, dData[0], dData[1], dData[2], dData[3], dData[4], dData[5], dData[6]);

if (thePanel == 0) {
opserr << "WARNING ran out of memory creating element with tag " << eleTag << endln;
delete [] theMaterial;
delete [] theMaterial2;
return 0;
}
return thePanel;
}


// typical constructor
MasonPan::MasonPan(int tag,
int Nd1, int Nd2, int Nd3, int Nd4, int Nd5, int Nd6,
int Nd7, int Nd8, int Nd9, int Nd10, int Nd11, int Nd12,
UniaxialMaterial &theMat, UniaxialMaterial &theMat2,
double a1, double a2, double d1, double d2, double thick,
double w1,double wr)
:Element(tag, 0),
externalNodes(12),
trans(1,24), L(0.0), A1(a1),A2(a2),D1(d1), D2(d2), TH(thick), W1(w1), WR(wr),
L1(0.0),L2(0.0),L3(0.0),L4(0.0),L5(0.0),L6(0.0)
{
// get a copy of the material object for our own use
// theMaterial = theMat.getCopy();
//if (theMaterial == 0) {
// opserr << "FATAL MassonPan::MasonPan() - out of memory, could not get a copy of the Material\n";
// exit(-1);
// }

// allocate memory for numMaterials1d uniaxial material models
theMaterial = new UniaxialMaterial* [6];
theMaterial2= new UniaxialMaterial

if ( theMaterial == 0 ) {
opserr << "FATAL MasonPan::MasonPan - failed to create a 1d material or direction array\n";
exit(-1);
}

// get a copy of the material and check we obtained a valid copy
for (int i=0; i<6; i++) {
theMaterial[i] = theMat[i]->getCopy();
if (theMaterial[i] == 0) {
opserr << "FATAL MasonPan::MasonPan - failed to get a copy of material " <<theMat[i]->getTag() << endln;
exit(-1);
}
}
theMaterial2= theMat2->getCopy;
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: New complex element

Post by fmk »

no. a number of obvious mistakes, i cannot see the header file so there could be others.

theMaterial2= 0; instead of theMaterial2= new UniaxialMaterial;
theMaterial[i] = theMat->getCopy(); instead of theMaterial[i] = theMat[i]->getCopy();
gst77
Posts: 18
Joined: Sat Nov 28, 2009 9:23 am
Location: UNCuyo

Re: New complex element

Post by gst77 »

Thank you Frank, it was very helpfull! The next time I will post the .h file too.
Post Reply