00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <stdlib.h>
00031
00032 #include <UniaxialMaterial.h>
00033 #include <UniaxialFiber2d.h>
00034 #include <FiberSection.h>
00035
00036 #include <ReinfBar.h>
00037 #include <Cell.h>
00038 #include <QuadPatch.h>
00039 #include <ReinfLayer.h>
00040 #include <FiberSectionRepr.h>
00041
00042
00043 FiberSectionRepr::FiberSectionRepr(int sectionID, int maxNumPatches, int maxNumReinfLayers)
00044 :SectionRepres(sectionID),
00045 sectID(sectionID),
00046 maxNPatches(maxNumPatches),
00047 maxNReinfLayers(maxNumReinfLayers),
00048 patch(0),
00049 reinfLayer(0),
00050 nPatches(0),
00051 nReinfLayers(0),
00052 numFibers(0),
00053 theFibers(0),
00054 sizeFibers(32)
00055 {
00056
00057 theFibers = new Fiber *[sizeFibers];
00058
00059 if (theFibers == 0) {
00060 opserr << "FiberSectionRepr::FiberSectionRepr -- failed to allocate Fiber pointers\n";
00061
00062 sizeFibers = 0;
00063 }
00064
00065 patch = new Patch*[maxNumPatches];
00066 if (!patch)
00067 {
00068 opserr << "FATAL ERROR: FiberSectionRepr - not enough memory to allocate " << maxNumPatches << " patches";
00069 exit (-1);
00070 }
00071 int i;
00072
00073 for (i=0; i< maxNumPatches; i++)
00074 patch[i] = 0;
00075
00076 reinfLayer = new ReinfLayer*[maxNumReinfLayers];
00077 if (!reinfLayer)
00078 {
00079 opserr << "FATAL ERROR: FiberSectionRepr - not enough memory to allocate " << maxNumReinfLayers << "reinforcing layers";
00080 exit (-1);
00081 }
00082
00083 for (i=0; i< maxNumReinfLayers; i++)
00084 reinfLayer[i] = 0;
00085
00086 }
00087
00088
00089 FiberSectionRepr::FiberSectionRepr(int sectionID)
00090 :SectionRepres(sectionID),
00091 sectID(sectionID),
00092 maxNPatches(0),
00093 maxNReinfLayers(0),
00094 patch(0), reinfLayer(0),
00095 nPatches(0),
00096 nReinfLayers(0)
00097 {
00098 opserr << "Function FiberSectionRepr::FiberSectionRepr not implemented yet";
00099 exit (-1);
00100 }
00101
00102
00103 FiberSectionRepr::FiberSectionRepr(int sectionID,
00104 int numPatches, Patch **patches,
00105 int numReinfLayers,
00106 ReinfLayer **reinfLayers)
00107 :SectionRepres(sectionID),
00108 sectID(sectionID),
00109 maxNPatches(numPatches),
00110 maxNReinfLayers(numReinfLayers),
00111 patch(patches), reinfLayer(reinfLayers),
00112 nPatches(numPatches),
00113 nReinfLayers(numReinfLayers)
00114 {
00115 opserr << "Function FiberSectionRepr::FiberSectionRepr not implemented yet";
00116 exit (-1);
00117 }
00118
00119
00120
00121 FiberSectionRepr::~FiberSectionRepr(void)
00122 {
00123 int i;
00124
00125 if (patch)
00126 {
00127 for (i = 0; i < maxNPatches; i++)
00128 if (patch[i] != 0)
00129 delete patch[i];
00130
00131 delete [] patch;
00132 }
00133
00134 if (reinfLayer)
00135 {
00136 for (i = 0; i < maxNReinfLayers; i++)
00137 if (reinfLayer[i] != 0)
00138 delete reinfLayer[i];
00139
00140 delete [] reinfLayer;
00141 }
00142
00143 if (theFibers != 0)
00144 delete [] theFibers;
00145
00146 }
00147
00148
00149 void FiberSectionRepr::setNumPatches (int numPatches)
00150 {
00151 opserr << "Function FiberSectionRepr::setnumPatches not implemented yet";
00152 exit (-1);
00153 }
00154
00155 int FiberSectionRepr::setPatches (Patch **patches)
00156 {
00157 opserr << "Function FiberSectionRepr::setPatches not implemented yet";
00158 exit (-1);
00159
00160 return 1;
00161 }
00162
00163 void FiberSectionRepr::setNumReinfLayers (int numReinfLayers)
00164 {
00165 opserr << "Function FiberSectionRepr::setnumReinfLayers not implemented yet";
00166 exit (-1);
00167 }
00168
00169 int FiberSectionRepr::setReinfLayers (ReinfLayer **reinfLayers)
00170 {
00171 opserr << "Function FiberSectionRepr::setReinfLayers not implemented yet";
00172 exit (-1);
00173
00174 return 1;
00175 }
00176
00177 int FiberSectionRepr::addPatch (const Patch & aPatch)
00178 {
00179 int error = 0;
00180
00181 if (nPatches < maxNPatches)
00182 patch[nPatches++] = aPatch.getCopy();
00183
00184
00185 else {
00186 maxNPatches *= 2;
00187 Patch **patches = new Patch*[maxNPatches];
00188 if (patches == 0) {
00189 opserr << "FiberSectionRepr::addPatch() - out of memory\n";
00190 return 1;
00191 }
00192 for (int i=0; i<nPatches; i++)
00193 patches[i] = patch[i];
00194 for (int j=nPatches; j<maxNPatches; j++)
00195 patches[j] = 0;
00196
00197 delete [] patch;
00198 patch = patches;
00199 patch[nPatches++] = aPatch.getCopy();
00200 }
00201
00202 return error;
00203 }
00204
00205 int FiberSectionRepr::addReinfLayer (const ReinfLayer & aReinfLayer)
00206 {
00207 int error = 0;
00208
00209 if (nReinfLayers < maxNReinfLayers)
00210 reinfLayer[nReinfLayers++] = aReinfLayer.getCopy();
00211
00212
00213
00214 else {
00215 maxNReinfLayers *= 2;
00216 ReinfLayer **reinfLayers = new ReinfLayer*[maxNReinfLayers];
00217 if (reinfLayers == 0) {
00218 opserr << "FiberSectionRepr::addReinLayer() - out of memory\n";
00219 return 1;
00220 }
00221 for (int i=0; i<nReinfLayers; i++)
00222 reinfLayers[i] = reinfLayer[i];
00223 for (int j=nReinfLayers; j<maxNReinfLayers; j++)
00224 reinfLayers[j] = 0;
00225
00226 delete [] reinfLayer;
00227 reinfLayer = reinfLayers;
00228 reinfLayer[nReinfLayers++] = aReinfLayer.getCopy();
00229 }
00230
00231 return error;
00232 }
00233
00234
00235 int FiberSectionRepr::getType (void) const
00236 {
00237 return SEC_TAG_FiberSection;
00238 }
00239
00240 int FiberSectionRepr::getNumPatches (void) const
00241 {
00242 return nPatches;
00243 }
00244
00245 int FiberSectionRepr::getNumReinfLayers (void) const
00246 {
00247 return nReinfLayers;
00248 }
00249
00250 Patch **
00251 FiberSectionRepr::getPatches (void) const
00252 {
00253 return patch;
00254 }
00255
00256 ReinfLayer **
00257 FiberSectionRepr::getReinfLayers (void) const
00258 {
00259 return reinfLayer;
00260 }
00261
00262
00263 void FiberSectionRepr::Print(OPS_Stream &s, int flag)
00264 {
00265
00266
00267 s << "\nSection representation type: Fiber Section";
00268 s << "\nMaximum Number of patches: " << maxNPatches;
00269 s << "\nMaximum Number of reinf. layers: " << maxNReinfLayers;
00270 s << "\nCurrent Number of patches: " << nPatches;
00271 s << "\nCurrent Number of reinf. layers: " << nReinfLayers;
00272
00273
00274
00275
00276
00277
00278
00279 }
00280
00281
00282 OPS_Stream &operator<<(OPS_Stream &s, FiberSectionRepr &fiberSectionRepr)
00283 {
00284 fiberSectionRepr.Print(s);
00285 return s;
00286 }
00287
00288
00289
00290 int
00291 FiberSectionRepr::addFiber(Fiber &newFiber)
00292 {
00293 if (numFibers < sizeFibers) {
00294
00295 theFibers[numFibers] = &newFiber;
00296 numFibers++;
00297 }
00298 else {
00299
00300 int newSize = 2*numFibers;
00301 if (newSize == 0)
00302 newSize = 2;
00303
00304 Fiber **newArray = new Fiber *[newSize];
00305
00306 if (newArray == 0) {
00307 opserr << "FiberSection::addFiber -- failed to allocate Fiber pointers\n";
00308 return -1;
00309 }
00310
00311
00312 sizeFibers = newSize;
00313
00314
00315 for (int i = 0; i < numFibers; i++)
00316 newArray[i] = theFibers[i];
00317
00318
00319 newArray[numFibers] = &newFiber;
00320 numFibers++;
00321
00322
00323 for (int j = numFibers; j < newSize; j++)
00324 newArray[j] = 0;
00325
00326 delete [] theFibers;
00327
00328 theFibers = newArray;
00329 }
00330
00331 return 0;
00332 }
00333
00334
00335 int
00336 FiberSectionRepr::getNumFibers(void) const
00337 {
00338 return numFibers;
00339 }
00340
00341 Fiber **
00342 FiberSectionRepr::getFibers(void) const
00343 {
00344 return theFibers;
00345 }