Dear Sir,
I meet a very strange problem. I build a new static analysis inside one element to solve a sub-structure,it use the LoadControl and Newton-Rahoson algorithm. The new analysis works well, and it can solve for the correct answer. But then in the Liner system of A*X=B, the Vector of B of this new analysis will be added to the Vector B of old analysis, then the old analysis cannot converge.I mean during the static analysis process of OpenSees I build another new static analysis.
This problem is very strange, because I build a new model, a new analysis, a new Linear SOE….After the analysis I also use something like:
NewAnalysis.clearAll( );
Sub_Domain->clearAll( );
I also delete all the nodes, the elements…..
I just don’t know why the Vector B of this new analysis will be added to the Vector B of the old analysis. So would you please tell me what I should use after this new analysis?( Something like the destructor?)
And would you please tell me this “add B function (BandGenLinSOE::addB)” is invoke by whom in the situation of “Static Analysis, Load Control, Newton-Raphson algorithm”?
I mean would you please tell me the possible “code in OpenSees” that add the Vector of B of the new analysis to the Vector B of old analysis?
Another problem is I can not define the the Linear SOE and Solver as “Public” in the element.
I mean in the ****element.h, I can not use:
include <BandGenLinLapackSolver .h>
include <BandSPDLinLapackSolver .h>
When I compile, the Visual Studio will say that “ Can not Open BandGenLinLapackSolver .h” even I have put these files in the same directly. So I can not define the the Linear SOE and Solver as “Public”. I have to use something like:
BandGenLinLapackSolver *theSolverA = new BandGenLinLapackSolver();
LinearSOE *theSOE1 = new BandGenLinSOE(*theSolverA);
It is really strange because I can include the Domain.h in the *element.h and I can define this new domain as “public”.
So would you please tell me why “ Can not Open BandGenLinLapackSolver .h”? Thank you very much for your guide.
Vector B is added twice to A*X=B
Moderators: silvia, selimgunay, Moderators
-
- Posts: 50
- Joined: Mon Jun 18, 2007 1:10 am
- Location: ROMA
it is not added if they are two separate objects. see code at bottom.
the addB is invoked by the integrators. have a look at the source code to see the exact code.
[code]
#include <stdlib.h>
#include <OPS_Globals.h>
#include <StandardStream.h>
// includes for the domain classes
#include <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 <AnalysisModel.h>
#include <Linear.h>
#include <PenaltyConstraintHandler.h>
#include <DOF_Numberer.h>
#include <RCM.h>
#include <LoadControl.h>
#include <BandSPDLinSOE.h>
#include <BandSPDLinLapackSolver.h>
// init the global variabled defined in OPS_Globals.h
StandardStream sserr;
OPS_Stream *opserrPtr = &sserr;
double ops_Dt = 0;
Element *ops_TheActiveElement = 0;
int buildAndAnalyze(Domain *theDomain) {
Node *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);
theDomain->addNode(node3);
theDomain->addNode(node4);
// create an elastic material using constriuctor:
// ElasticMaterialModel(tag, E)
UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000);
// create the truss elements using constructor:
// Truss(tag, dim, nd1, nd2, Material &,A)
// and then add them to the domain
Truss *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 single-point constraint objects using constructor:
// SP_Constraint(tag, nodeTag, dofID, value)
// and then add them to the domain
SP_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 = 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->addSP_Constraint(sp5);
theDomain->addSP_Constraint(sp6);
// construct a linear time series object using constructor:
// LinearSeries()
TimeSeries *theSeries = new LinearSeries();
// construct a load pattren using constructor:
// LoadPattern(tag)
// and then set it's TimeSeries and add it to the domain
LoadPattern *theLoadPattern = new LoadPattern(1);
theLoadPattern->setTimeSeries(theSeries);
theDomain->addLoadPattern(theLoadPattern);
// construct a nodal load using constructor:
// NodalLoad(tag, nodeID, Vector &)
// first construct a Vector of size 2 and set the values NOTE C INDEXING
// then construct the load and add it to the domain
Vector theLoadValues(2);
theLoadValues(0) = 100.0;
theLoadValues(1) = -50.0;
NodalLoad *theLoad = new NodalLoad(1, 4, theLoadValues);
theDomain->addNodalLoad(theLoad, 1);
AnalysisModel *theModel = new AnalysisModel();
EquiSolnAlgo *theSolnAlgo = new 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 = new DOF_Numberer(*theRCM);
BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver();
LinearSOE *theSOE = new BandSPDLinSOE(*theSolver);
StaticAnalysis theAnalysis(*theDomain,
*theHandler,
*theNumberer,
*theModel,
*theSolnAlgo,
*theSOE,
*theIntegrator);
// perform the analysis & print out the results for the domain
int numSteps = 1;
theAnalysis.analyze(numSteps);
opserr << "VECTOR X: " << theSOE->getX();
opserr << "VECTOR B: " << theSOE->getB();
}
// main routine
int main(int argc, char **argv)
{
Domain *theDomain1 = new Domain();
Domain *theDomain2 = new Domain();
Node *theNode = 0;
buildAndAnalyze(theDomain1);
theNode = theDomain1->getNode(4);
opserr << "AFTER BUILD 1 - NODe 4 DOMAIN 1: " << *theNode;
buildAndAnalyze(theDomain2);
theNode = theDomain1->getNode(4);
opserr << "AFTER BUILD 1 - NODe 4 DOMAIN 1: " << *theNode;
theNode = theDomain2->getNode(4);
opserr << "AFTER BUILD 1 - NODe 4 DOMAIN 2: " << *theNode;
exit(0);
}
[/code]
the addB is invoked by the integrators. have a look at the source code to see the exact code.
[code]
#include <stdlib.h>
#include <OPS_Globals.h>
#include <StandardStream.h>
// includes for the domain classes
#include <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 <AnalysisModel.h>
#include <Linear.h>
#include <PenaltyConstraintHandler.h>
#include <DOF_Numberer.h>
#include <RCM.h>
#include <LoadControl.h>
#include <BandSPDLinSOE.h>
#include <BandSPDLinLapackSolver.h>
// init the global variabled defined in OPS_Globals.h
StandardStream sserr;
OPS_Stream *opserrPtr = &sserr;
double ops_Dt = 0;
Element *ops_TheActiveElement = 0;
int buildAndAnalyze(Domain *theDomain) {
Node *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);
theDomain->addNode(node3);
theDomain->addNode(node4);
// create an elastic material using constriuctor:
// ElasticMaterialModel(tag, E)
UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000);
// create the truss elements using constructor:
// Truss(tag, dim, nd1, nd2, Material &,A)
// and then add them to the domain
Truss *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 single-point constraint objects using constructor:
// SP_Constraint(tag, nodeTag, dofID, value)
// and then add them to the domain
SP_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 = 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->addSP_Constraint(sp5);
theDomain->addSP_Constraint(sp6);
// construct a linear time series object using constructor:
// LinearSeries()
TimeSeries *theSeries = new LinearSeries();
// construct a load pattren using constructor:
// LoadPattern(tag)
// and then set it's TimeSeries and add it to the domain
LoadPattern *theLoadPattern = new LoadPattern(1);
theLoadPattern->setTimeSeries(theSeries);
theDomain->addLoadPattern(theLoadPattern);
// construct a nodal load using constructor:
// NodalLoad(tag, nodeID, Vector &)
// first construct a Vector of size 2 and set the values NOTE C INDEXING
// then construct the load and add it to the domain
Vector theLoadValues(2);
theLoadValues(0) = 100.0;
theLoadValues(1) = -50.0;
NodalLoad *theLoad = new NodalLoad(1, 4, theLoadValues);
theDomain->addNodalLoad(theLoad, 1);
AnalysisModel *theModel = new AnalysisModel();
EquiSolnAlgo *theSolnAlgo = new 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 = new DOF_Numberer(*theRCM);
BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver();
LinearSOE *theSOE = new BandSPDLinSOE(*theSolver);
StaticAnalysis theAnalysis(*theDomain,
*theHandler,
*theNumberer,
*theModel,
*theSolnAlgo,
*theSOE,
*theIntegrator);
// perform the analysis & print out the results for the domain
int numSteps = 1;
theAnalysis.analyze(numSteps);
opserr << "VECTOR X: " << theSOE->getX();
opserr << "VECTOR B: " << theSOE->getB();
}
// main routine
int main(int argc, char **argv)
{
Domain *theDomain1 = new Domain();
Domain *theDomain2 = new Domain();
Node *theNode = 0;
buildAndAnalyze(theDomain1);
theNode = theDomain1->getNode(4);
opserr << "AFTER BUILD 1 - NODe 4 DOMAIN 1: " << *theNode;
buildAndAnalyze(theDomain2);
theNode = theDomain1->getNode(4);
opserr << "AFTER BUILD 1 - NODe 4 DOMAIN 1: " << *theNode;
theNode = theDomain2->getNode(4);
opserr << "AFTER BUILD 1 - NODe 4 DOMAIN 2: " << *theNode;
exit(0);
}
[/code]