版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、OpenSees 開發(fā)(二)源碼分析這是一個平面桁架靜力分析算例,代碼位于 OpenSees2.3.0EXAMPLESExample1main.cpp這里先給出原始源代碼:cpp view plain copy / standard C+ includes#include<stdlib.h> #include <OPS_Globals.h>#include <StandardStream.h> #include <ArrayOfTaggedObjects.h> / includes for the domain classes #include
2、<Domain.h> #include <Node.h> #include <Truss.h> #include <ElasticMaterial.h> #include <SP_Constraint.h>#include <LoadPattern.h> #include <LinearSeries.h> #include <NodalLoad.h>/ includes for the analysis classes#include<StaticAnalysis.h>#include
3、<AnalysisModel.h>#include <Linear.h> #include <PenaltyConstraintHandler.h> #include <DOF_Numberer.h> #include <RCM.h>#include <LoadControl.h> #include <BandSPDLinSOE.h> #include/ init the global<BandSPDLinLapackSolver.h>variabled defined in OPS_Globals
4、.hStandardStreamsserr; OPS_Stream *opserrPtr = &sserr;doubleops_Dt = 0; / Domain *ops_TheActiveDomain = 0; Element *ops_TheActiveElement = 0; / main routine int main(int argc, char *argv) / / now create a domain and a modelbuilder/ andbuild the model/Domain *theDomain =new Domain();/ create the
5、nodes usingconstructor:/Node(tag, ndof, crd1, crd2)/ and then add them to the domainNode*node1 = new Node(1, 2,0.0,0.0);Node*node2 = new Node(2, 2, 144.0,0.0);Node *node3= new Node(3, 2, 168.0, 0.0);Node *node4 =new Node(4, 2, 72.0, 96.0);theDomain->addNode(node1);theDomain->addNode(node2);the
6、Domain->addNode(node3);theDomain->addNode(node4);/ create anelastic material using constriuctor:/ElasticMaterialModel(tag, E)UniaxialMaterialtheMaterial = new ElasticMaterial(1, 3000);/create the truss elements using constructor: / Truss(tag, dim, nd1, nd2, Material &,A)/ andthen add them
7、to the domainTruss *truss1 =new Truss(1, 2, 1, 4, *theMaterial, 10.0);Truss*truss2 = new Truss(2, 2, 2, 4, *theMaterial,5.0);Truss *truss3 = new Truss(3, 2, 3, 4, *theMaterial, 5.0); theDomain->addElement(truss1); theDomain->addElement(truss2);theDomain->addElement(truss3); / create the sin
8、gle-point constraint objects using constructor: /SP_Constraint(tag, nodeTag, dofID, value)/and then add them to the domainSP_Constraint *sp1 = new SP_Constraint(1, 1, 0, 0.0);SP_Constraint *sp2 = new SP_Constraint(2, 1, 1, 0.0);SP_Constraint *sp3 = new SP_Constraint(3, 2, 0, 0.0);SP_Constraint *sp4
9、= new SP_Constraint(4, 2, 1, 0.0);SP_Constraint *sp5 = new SP_Constraint(5, 3, 0, 0.0);SP_Constraint *sp6 = new SP_Constraint(6, 3, 1, 0.0); theDomain->addSP_Constraint(sp1); theDomain->addSP_Constraint(sp2); theDomain->addSP_Constraint(sp3); theDomain->addSP_Constraint(sp4);theDomain-&g
10、t;addSP_Constraint(sp5); theDomain->addSP_Constraint(sp6); / construct a linear time series object using constructor: / LinearSeries() TimeSeries *theSeries = new LinearSeries();/ construct a loadpattren using constructor: / LoadPattern(tag) / and then set its TimeSeries and add it to the domain
11、LoadPattern *theLoadPattern = new LoadPattern(1); theLoadPattern->setTimeSeries(theSeries); theDomain->addLoadPattern(theLoadPattern);/ construct a nodal load using constructor:/NodalLoad(tag, nodeID, Vector &)/ firstconstruct a Vector of size 2 and set the values NOTE C INDEXING/ then con
12、struct the load and add it tothe domainVector theLoadValues(2);theLoadValues(0) = 100.0; theLoadValues(1) = -50.0;NodalLoad *theLoad = new NodalLoad(1, 4,theLoadValues);theDomain->addNodalLoad(theLoad, 1); / create an Analysis object to perform a static analysis of the model / - constructs: / Ana
13、lysisModel oftype AnalysisModel,/EquiSolnAlgo of typeLinear /StaticIntegrator of type LoadControl/ ConstraintHandler of type Penalty / DOF_Numberer which uses RCM / LinearSOEof type Band SPD/ and then the StaticAnalysisobjectAnalysisModel *theModel = newAnalysisModel();EquiSolnAlgo *theSolnAlgo= new
14、 Linear();StaticIntegrator *theIntegrator =new LoadControl(1.0, 1, 1.0, 1.0);ConstraintHandler*theHandler = new PenaltyConstraintHandler(1.0e8,1.0e8);RCM*theRCM = new RCM();DOF_Numberer*theNumberer = newDOF_Numberer(*theRCM); BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver();LinearSOE*theSO
15、E = newBandSPDLinSOE(*theSolver);StaticAnalysistheAnalysis(*theDomain,*theHandler,*theNumberer,*theModel,*theSolnAlgo,*theSOE,*theIntegrator); /perform the analysis & print out the results for the domain int numSteps = 1;opserr <<theAnalysis.analyze(numSteps);*theDomain; 代碼:exit(0); 接下去一步一
16、步解釋cpp view plain copy / 創(chuàng)建一個有限元模型 Domain *theDomain = new Domain();cpp view plain copy / 創(chuàng)建 4 個節(jié)點,詳細見說明 1 Node *node1 = new Node(1, 2,0.0, 0.0); Node *node2 =new Node(2, 2, 144.0,0.0); Node *node3 = newNode(3, 2, 168.0, 0.0);Node *node4 = new Node(4,2, 72.0, 96.0);說明 1: Node 構造函數(shù)位于 OpenSees2.3.0SRC
17、domainnodeNode.cpp 源碼定義如下:*Node:Node(int tag, int ndof, double Crd1, double Crd2):DomainComponent(tag,NOD_TAG_Node),numberDOF(ndof), theDOF_GroupPtr(0),Crd = new Vector(2);(*Crd)(0) = Crd1;(*Crd)(1) = Crd2;*參數(shù) tag 為該節(jié)點的標簽,指定給基類 :DomainComponent(tag,NOD_TAG_Node), NOD_TAG_Node 是一個枚舉值,表明該 DomainCompon
18、ent 對象是一個節(jié)點類型;ndof 該節(jié)點的自由度,本例中,節(jié)點都為兩個自由度;Crd1, Crd2 為該 2 維節(jié)點的坐標,賦于成員變量 Crd ,這是 一個類數(shù)組的數(shù)據(jù)類型,創(chuàng)建了一個含該點坐標信息的數(shù)組。cpp view plain copy / 將 4 個節(jié)點對象加入有限元模型中/ 如果兩個 node 對象 tag 相同,則會返回失敗 theDomain->addNode(node1); theDomain->addNode(node2); theDomain->addNode(node3);theDomain->addNode(node4);cpp view
19、 plain copy /創(chuàng)建一個彈性材料, 見說明 2 UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000);說明 2 :創(chuàng)建材料對象*UniaxialMaterial *theMaterial = newElasticMaterial(1,3000);*UniaxialMaterial 類官方說明: /OpenSees/api/doxygen2/ht ml/classElasticMaterial.html其中, ElasticMaterial 為 UniaxialMa
20、terial 派生類意為理想彈性材料 /wiki/index.php/Elastic_Uniaxi al_Material構造函數(shù)申明:*ElasticMaterial(int tag, double E, double eta =0.0);*實現(xiàn):*ElasticMaterial:ElasticMaterial(int tag, double e, doubleet):UniaxialMaterial(tag,MAT_TAG_ElasticMaterial), trialStrain(0.0), trialStrainRate(0.0),
21、 E(e), eta(et), parameterID(0)*其中,第一個參數(shù) tag 為標簽,傳遞給基類構造函數(shù), e 為 彈性模型, et 為材料阻尼比, 默認為 0.cpp view plain copy / 創(chuàng)建一個工況,編號為 1,暫時未知 LoadPattern *theLoadPattern = new LoadPattern(1); theDomain->addLoadPattern(theLoadPattern); / 暫 時未知這句話什么意思 theLoadPattern->setTimeSeries(new LinearSeries(); / 創(chuàng)建一個節(jié)點荷載
22、向量 Vector theLoadValues(2); theLoadValues(0) = 100.0;theLoadValues(1) = -50.0;/ 第一個參數(shù) tag 標簽,第二個參數(shù)表明施加點荷載的節(jié)點 tag ,第三個參數(shù)是一個向量,表明在第一維度施加 100 個 單位力,第二維度施加反方向 50 單位力 NodalLoad *theLoad = new NodalLoad(1, 4, theLoadValues);/ 將NodalLoad 對象加入模型, 1 表示加入的工況編號 theDomain->addNodalLoad(theLoad, 1); / 如果new N
23、odalLoad 后的節(jié)點編號未在模型中找到,返回失敗/ 如果 addNodalLoad 第 2 個參數(shù)所表示的工況編號不存在, 返回失敗 這里為了避免內(nèi)存泄漏,也為了使代碼的封裝性更強,我更 改了一部分代碼:cpp view plain copy AnalysisModel*theModel = newAnalysisModel(); EquiSolnAlgo *theSolnAlgo = new Linear(); StaticIntegrator *theIntegrator = new LoadControl(1.0, 1, 1.0, 1.0); ConstraintHandler *
24、theHandler = new PenaltyConstraintHandler(1.0e8,1.0e8); RCM*theRCM = new RCM();DOF_Numberer*theNumberer = newDOF_Numberer(*theRCM); BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver();LinearSOE*theSOE = newBandSPDLinSOE(*theSolver); StaticAnalysis theAnalysis(*theDomain, *theHandler,*theNumbe
25、rer, *theModel, *theSolnAlgo, *theSOE, *theIntegrator); 改為:cpp view plain copy / 分析對象封裝 structMyStaticAnalysis : public StaticAnalysis ConstraintHandler *pConstraintHandler;DOF_Numberer*pDOF_Numberer;AnalysisModel*pAnalysisModel;EquiSolnAlgo*pEquiSolnAlgo; LinearSOE*pLinearSOE;StaticIntegrator *pSta
26、ticIntegrator;MyStaticAnalysis(Domain *theDomain) :StaticAnalysis(*theDomain, *(pConstraintHandler = newPenaltyConstraintHandler(1.0e8,1.0e8), *(pDOF_Numberer = new DOF_Numberer(*(new RCM(),*(pAnalysisModel = new AnalysisModel(),*(pEquiSolnAlgo = new Linear(), *(pLinearSOE = new BandSPDLinSOE(*(new BandSPDLinLapackSolver(),*(pStaticIntegrator = new LoadControl(1.0, 1, 1.0, 1.0) MyStaticAnalysis()delete pConstraintHandler;delete pDOF_Numberer;delete pAnalysisModel;delete pEquiSolnAlgo;delete pLinearSOE;delete pStaticIntegrator; ;cpp view plai
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《大學班會》課件
- 2020版 滬教版 高中音樂 必修2 歌唱 上篇《第一單元氣韻生動》大單元整體教學設計2020課標
- 《塑膠模具設計》課件
- 合建合同范本
- 《外科手術中的告知》課件
- 2025年青海貨運從業(yè)資格考試模擬考試題庫答案大全
- 2025年資陽c1貨運從業(yè)資格證考試內(nèi)容
- 2025年慶陽a2貨運從業(yè)資格證模擬考試題
- 2025年吉林道路運輸從業(yè)資格證考試
- 2025年山西年貨運從業(yè)資格證考試從業(yè)從業(yè)資格資格題庫及答案
- 中心靜脈深靜脈導管維護操作評分標準
- 甘肅甕福公司招聘考試題
- UPS維保方案 文檔
- 病理組織切片技術課件
- 2024年中國電商行業(yè)分析報告
- 項目管理提升總結匯報
- 職業(yè)生涯規(guī)劃公務員
- 電力系統(tǒng)安全穩(wěn)定控制系統(tǒng)技術規(guī)范
- 彈性力學-012第十二章-彈性波的傳播
- 農(nóng)村房屋建設技術方案
- 四川省成都市2023-2024學年八年級上學期期末數(shù)學試題(無答案)
評論
0/150
提交評論