Hi, Thanks for the reply. Here is the model that needs to be created in C++.
#include <stdio.h>
#include <string.h>
#include <math.h>
#include “MyProfile.h”
#include “Element.h”
#include “Node.h”
#define PI 3.14159265359
// constructor
MyProfile::MyProfile(const char* pName,
double hr, double br, double tr,double hL, double bL, double tL, double d0,double di) :
Profile(pName)
{
// copy input data
this->hr = hr;
this->br = br;
this->tr = tr;
this->hL = hL;
this->bL = bL;
this->tL = tL;
this->d0 = d0;
this->di = di;
// check the data
Check();
// create the profile
Create();
}
//double d0
//double di
//double tT =(d0 - di)/2.; //tube thickness.
// Check the profile’s data
int MyProfile::Check()
{
double dEps = 0.5;
double tT =(d0 - di)/2.; //tube thickness.
if (hr < 3.*tr) throw “error: h of Hollow Rectangle Profile invalid!”;
if (br < 3.*tr) throw “error: b of Hollow Rectangle Profile invalid!”;
if (tr < dEps) throw “error: t of Hollow Rectangle Profile invalid!”;
if (hL < 3.*tL) throw “error: h of L Profile invalid!”;
if (bL < 3.*tL) throw “error: b of L Profile invalid!”;
if (tL < dEps) throw “error: t of L Profile invalid!”;
if (d0 < 3.*tT) throw “error: outer diameter of Circle Profile invalid!”;
if (di < 3.*tT) throw “error: inner diameter of Circle Profile invalid”;
return 1;
}
// create the geometry
int MyProfile::Create()
{
// add node and element space
AddNodeContainer(32); // For the number of nodes = 32
AddElementContainer(32); // For the number of elements = 32
double dR = hr/2. - tr/2. ;
double dL = (bL - (tL/2.));
double dK = (hL - (tL/2.));
double tT =(d0 - di)/2.; //tube thickness.
double tube_r = (di + tT)/2.;
double c_x = (hr/2.) + dL ; // X cordinate of tube centre
double c_y = dK + tube_r; // Y cordinate of tube centre
// creation of the nodes
Node* pN[32];
pN[0] = new Node( 1, -dR, 0);
pN[1] = new Node( 2, dR, 0);
pN[2] = new Node( 3, -dR, (br - tr));
pN[3] = new Node( 4, dR, -(br - tr));
pN[4] = new Node( 5, -hr/2., 0);
pN[5] = new Node( 6, -((hr/2)+dL), 0);
pN[6] = new Node( 7, -(c_x + (tube_r*cos(270*(PI/180.)))), c_y + (tube_r*sin(270*(PI/180.))));
pN[7] = new Node( 8, -(c_x + (tube_r*cos(300*(PI/180.)))), c_y + (tube_r*sin(300*(PI/180.))));
pN[8] = new Node( 9, -(c_x + (tube_r*cos(330*(PI/180.)))), c_y + (tube_r*sin(330*(PI/180.))));
pN[9] = new Node(10, -(c_x + (tube_r*cos(0*(PI/180.)))), c_y + (tube_r*sin(0*(PI/180.))));
pN[10] = new Node(11, -(c_x + (tube_r*cos(30*(PI/180.)))), c_y + (tube_r*sin(30*(PI/180.))));
pN[11] = new Node(12, -(c_x + (tube_r*cos(60*(PI/180.)))), c_y + (tube_r*sin(60*(PI/180.))));
pN[12] = new Node(13, -(c_x + (tube_r*cos(90*(PI/180.)))), c_y + (tube_r*sin(90*(PI/180.))));
pN[13] = new Node(14, -(c_x + (tube_r*cos(120*(PI/180.)))), c_y + (tube_r*sin(120*(PI/180.))));
pN[14] = new Node(15, -(c_x + (tube_r*cos(150*(PI/180.)))), c_y + (tube_r*sin(150*(PI/180.))));
pN[15] = new Node(16, -(c_x + (tube_r*cos(180*(PI/180.)))), c_y + (tube_r*sin(180*(PI/180.))));
pN[16] = new Node(17, -(c_x + (tube_r*cos(210*(PI/180.)))), c_y + (tube_r*sin(210*(PI/180.))));
pN[17] = new Node(18 , -(c_x + (tube_r*cos(240*(PI/180.)))), c_y + (tube_r*sin(240*(PI/180.))));
pN[18] = new Node(19, hr/2., 0);
pN[19] = new Node(20, ((hr/2)+dL), 0);
pN[20] = new Node(21, (c_x + (tube_r*cos(270*(PI/180.)))), c_y + (tube_r*sin(270*(PI/180.))));
pN[21] = new Node(22, (c_x + (tube_r*cos(300*(PI/180.)))), c_y + (tube_r*sin(300*(PI/180.))));
pN[22] = new Node(23, (c_x + (tube_r*cos(330*(PI/180.)))), c_y + (tube_r*sin(330*(PI/180.))));
pN[23] = new Node(24, (c_x + (tube_r*cos(0*(PI/180.)))), c_y + (tube_r*sin(0*(PI/180.))));
pN[24] = new Node(25, (c_x + (tube_r*cos(30*(PI/180.)))), c_y + (tube_r*sin(30*(PI/180.))));
pN[25] = new Node(26, (c_x + (tube_r*cos(60*(PI/180.)))), c_y + (tube_r*sin(60*(PI/180.))));
pN[26] = new Node(27, (c_x + (tube_r*cos(90*(PI/180.)))), c_y + (tube_r*sin(90*(PI/180.))));
pN[27] = new Node(28, (c_x + (tube_r*cos(120*(PI/180.)))), c_y + (tube_r*sin(120*(PI/180.))));
pN[28] = new Node(29, (c_x + (tube_r*cos(150*(PI/180.)))), c_y + (tube_r*sin(150*(PI/180.))));
pN[29] = new Node(30, (c_x + (tube_r*cos(180*(PI/180.)))), c_y + (tube_r*sin(180*(PI/180.))));
pN[30] = new Node(31, (c_x + (tube_r*cos(210*(PI/180.)))), c_y + (tube_r*sin(210*(PI/180.))));
pN[31] = new Node(32, (c_x + (tube_r*cos(240*(PI/180.)))), c_y + (tube_r*sin(240*(PI/180.))));
// creation of the elements
Element* pE[32];
pE[0] = new Element(1, pN[0], pN[1], tr);
pE[1] = new Element(2, pN[1], pN[2], tr);
pE[2] = new Element(3, pN[2], pN[3], tr);
pE[3] = new Element(4, pN[3], pN[4], tr);
pE[4] = new Element(5, pN[0], pN[5], tL);
pE[5] = new Element(6, pN[5], pN[6], tL);
pE[6] = new Element(7, pN[6], pN[7], tT);
pE[7] = new Element(8, pN[7], pN[8], tT);
pE[8] = new Element(9, pN[8], pN[9], tT);
pE[9] = new Element(10, pN[9], pN[10], tT);
pE[10] = new Element(11, pN[10], pN[11], tT);
pE[11] = new Element(12, pN[11], pN[12], tT);
pE[12] = new Element(13, pN[12], pN[13], tT);
pE[13] = new Element(14, pN[13], pN[14], tT);
pE[14] = new Element(15, pN[14], pN[15], tT);
pE[15] = new Element(16, pN[15], pN[16], tT);
pE[16] = new Element(17, pN[16], pN[17], tT);
pE[17] = new Element(18, pN[6], pN[17], tT);
pE[18] = new Element(19, pN[1], pN[18], tL);
pE[19] = new Element(20, pN[18], pN[19], tL);
pE[20] = new Element(21, pN[19], pN[20], tT);
pE[21] = new Element(22, pN[20], pN[21], tT);
pE[22] = new Element(23, pN[21], pN[22], tT);
pE[23] = new Element(24, pN[22], pN[23], tT);
pE[24] = new Element(25, pN[23], pN[24], tT);
pE[25] = new Element(26, pN[24], pN[25], tT);
pE[26] = new Element(27, pN[25], pN[26], tT);
pE[27] = new Element(28, pN[26], pN[27], tT);
pE[28] = new Element(29, pN[27], pN[28], tT);
pE[29] = new Element(30, pN[28], pN[29], tT);
pE[30] = new Element(31, pN[29], pN[30], tT);
pE[31] = new Element(32, pN[19], pN[30], tT);
// add elements to the profile
for (int i=0;i<32;i++) AddElement(pE[i]);
return 1;
}
// list all profile data
void MyProfile::List()
{
// list input data
sprintf(pMsg,“Profile name…: %s\n”,pName);
appendLog(pMsg);
sprintf(pMsg," Hollow Rectangle Profile Length …: %10.2f mm\n",hr);
appendLog(pMsg);
sprintf(pMsg," Hollow Rectangle Profile Width …: %10.2f mm\n",br);
appendLog(pMsg);
sprintf(pMsg," Hollow Rectangle Profile Thickness…: %10.2f mm\n",tr);
appendLog(pMsg);
sprintf(pMsg," L-profile height…: %10.2f mm\n",hL);
appendLog(pMsg);
sprintf(pMsg," L-profile width…: %10.2f mm\n",bL);
appendLog(pMsg);
sprintf(pMsg," L-profile thickness…: %10.2f mm\n",tL);
appendLog(pMsg);
sprintf(pMsg," Outer diameter of the circle…: %10.2f mm\n",d0);
appendLog(pMsg);
sprintf(pMsg," Inner diameter of the circle…: %10.2f mm\n",di);
appendLog(pMsg);
// call the base class's methods!
Profile::List();
}
I tried few instances to use loop but was unsuccesful. Thanks again. I appreciate the help.