NeoPZ
pzsmanal.cpp
Go to the documentation of this file.
1 
6 #include "pzsmanal.h"
7 #include "pzsubcmesh.h"
8 #include "pzfmatrix.h"
9 #include "pzstrmatrix.h"
10 #include "pzsolve.h"
11 
12 #include "pzlog.h"
13 
14 #ifdef LOG4CXX
15 static LoggerPtr logger(Logger::getLogger("pz.analysis.pzsmanalysis"));
16 
17 #endif
18 
19 using namespace std;
20 
21 // Construction/Destruction
22 
24 TPZAnalysis(mesh,true), fReducableStiff(0){
25  fMesh = mesh;
26  if (fMesh)
27  {
29  }
30 }
31 
33 {
34 
35 }
36 
38 void TPZSubMeshAnalysis::SetCompMesh(TPZCompMesh * mesh, bool mustOptimizeBandwidth)
39 {
40  TPZSubCompMesh *submesh = dynamic_cast<TPZSubCompMesh *>(mesh);
41  if (submesh) {
42  fMesh = submesh;
43  }
44  else
45  {
46  DebugStop();
47  }
48  TPZAnalysis::SetCompMesh(mesh, mustOptimizeBandwidth);
49  if (fCompMesh) {
51  }
52 }
53 
54 
55 
57 
58 
59  TPZCompMesh *mesh = Mesh();
60  TPZSubCompMesh *submesh = dynamic_cast<TPZSubCompMesh *>(mesh);
61  if (!submesh) {
62  DebugStop();
63  }
64  TPZCompMesh *fathermesh = submesh->Mesh();
65  if (fathermesh->NElements() < 50)
66  {
67  std::cout << "Assembling the SubCompMesh index " << fMesh->Index() << std::endl;
68  }
69  int numeq = fCompMesh->NEquations();
70  int numinternal = fMesh->NumInternalEquations();
71  fReferenceSolution.Redim(numeq,1);
72  fRhs.Redim(numeq,1);
73  if(!fReducableStiff)
74  {
76  }
77  fReducableStiff->Redim(numeq,numinternal);
79  if(!fSolver->Matrix())
80  {
81  if (fStructMatrix->HasRange()) {
82  DebugStop();
83  }
84  fStructMatrix->SetEquationRange(0, numinternal);
85  fSolver->SetMatrix(fStructMatrix->Create());
86  fStructMatrix->EquationFilter().Reset();
87  }
89  // fReducableStiff.SetK00(fSolver->Matrix());
90  // this will initialize fK00 too
91  matred->SetSolver(dynamic_cast<TPZMatrixSolver<STATE> *>(fSolver->Clone()));
92  // TPZStructMatrix::Assemble(fReducableStiff,fRhs, *fMesh);
93 // time_t before = time (NULL);
95 
96  matred->SetF(fRhs);
97 // time_t after = time(NULL);
98 // double diff = difftime(after, before);
99 // std::cout << __PRETTY_FUNCTION__ << " tempo " << diff << std::endl;
100 }
101 
102 void TPZSubMeshAnalysis::Run(std::ostream &out){
103 
104  //fReducableStiff.Print("Reducable stiff before assembled");
106 // time_t tempo = time(NULL);
107  Assemble();
108 // time_t tempodepois = time(NULL);
109 // double elapsedtime = difftime(tempodepois, tempo);
110 
111 // std::cout << "Tempo para assemblagem " << elapsedtime << std::endl;
112  if (!fReducableStiff) {
113  DebugStop();
114  }
116  if(!matred)
117  {
118  DebugStop();
119  }
120 }
122 // time_t tempo = time(NULL);
123  if (!fReducableStiff) {
124  DebugStop();
125  }
127 #ifdef LOG4CXX
128  if(logger->isDebugEnabled())
129  {
130  std::stringstream sout;
131  matred->Print("Before = ",sout,EMathematicaInput);
132  LOGPZ_DEBUG(logger, sout.str())
133  }
134 #endif
135  matred->K11Reduced(ek, ef);
136 
137 // time_t tempodepois = time(NULL);
138 // double elapsedtime = difftime(tempodepois, tempo);
139 
140 // std::cout << "Tempo para inversao " << elapsedtime << std::endl;
141 
142 }
143 
146 {
147  if (!fReducableStiff) {
148  DebugStop();
149  }
151 #ifdef LOG4CXX
152  if(logger->isDebugEnabled())
153  {
154  std::stringstream sout;
155  matred->Print("Before = ",sout,EMathematicaInput);
156  LOGPZ_DEBUG(logger, sout.str())
157  }
158 #endif
159  matred->SetF(fRhs);
160  matred->F1Red(rhs);
161 
162 }
163 
164 
166 {
167 
168  // sol.Print("sol");
169  int numinter = fMesh->NumInternalEquations();
170  int numeq = fMesh->TPZCompMesh::NEquations();
171  TPZFMatrix<STATE> soltemp(numeq-numinter,1,0.);
172  int i;
173  for(i=0; i<numeq-numinter; i++) {
174  soltemp(i,0) = sol.GetVal(numinter+i,0)-fReferenceSolution(numinter+i,0);
175  }
176  TPZFMatrix<STATE> uglobal(numeq,1,0.);
177  if(fReducableStiff)
178  {
180  matred->UGlobal(soltemp,uglobal);
181  fSolution = fReferenceSolution + uglobal;
182  }
183 #ifdef LOG4CXX
184  if (logger->isDebugEnabled()) {
185  std::stringstream sout;
186  soltemp.Print("External DOF Solution",sout);
187  uglobal.Print("Expanded solution",sout);
188  fSolution.Print("fSolution",sout);
189  LOGPZ_DEBUG(logger, sout.str())
190  }
191 #endif
193 }
194 
196  return Hash("TPZSubMeshAnalysis") ^ TPZAnalysis::ClassId() << 1;
197 }
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
TPZMatrixSolver< STATE > * fSolver
Type of solver to be applied.
Definition: pzanalysis.h:52
void SetMaxNumberRigidBodyModes(int maxrigid)
indicate how many degrees of freedom are reserved for rigid body modes
Definition: pzmatred.h:162
virtual ~TPZSubMeshAnalysis()
Destructor.
Definition: pzsmanal.cpp:32
void Run(std::ostream &out) override
Run: assemble the stiffness matrix.
Definition: pzsmanal.cpp:102
TPZAutoPointer< TPZMatrix< STATE > > fReducableStiff
Stiffness matrix to sub mesh.
Definition: pzsmanal.h:27
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
TPZFMatrix< STATE > fSolution
Solution vector.
Definition: pzanalysis.h:50
Analysis procedure to computational sub mesh. Analysis.
Definition: pzsmanal.h:20
void F1Red(TPZFMatrix< TVar > &F1)
Computes the reduced version of the right hand side .
Definition: pzmatred.cpp:171
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
void UGlobal(const TPZFMatrix< TVar > &U1, TPZFMatrix< TVar > &result)
Computes the complete vector based on the solution u1.
Definition: pzmatred.cpp:342
int ClassId() const override
Define the class id associated with the class.
TPZCompMesh * fCompMesh
Computational mesh.
Definition: pzanalysis.h:44
TPZSubMeshAnalysis(TPZSubCompMesh *mesh=0)
Constructor: create an object analysis from one mesh.
Definition: pzsmanal.cpp:23
void SetF(const TPZFMatrix< TVar > &F)
Copies the F vector in the internal data structure.
Definition: pzmatred.cpp:140
TPZCompMesh * Mesh() const
Returns the pointer to the computational mesh.
Definition: pzanalysis.h:180
int NumberRigidBodyModes()
Return the number of rigid body modes associated with the internal degrees of freedom.
virtual void SetCompMesh(TPZCompMesh *mesh, bool mustOptimizeBandwidth) override
Set the computational mesh of the analysis.
Definition: pzsmanal.cpp:38
Contains the TPZStructMatrixOR class which responsible for a interface among Matrix and Finite Elemen...
void ReducedRightHandSide(TPZFMatrix< STATE > &rhs)
compute the reduced right hand side using the current stiffness. Abort if there is no stiffness compu...
Definition: pzsmanal.cpp:145
virtual void Assemble() override
Assemble the global stiffness matrix and put it into the reducable stiffness matrix.
Definition: pzsmanal.cpp:56
void SetSolver(TPZAutoPointer< TPZMatrixSolver< TVar > > solver)
Definition: pzmatred.cpp:125
TPZAutoPointer< TPZGuiInterface > fGuiInterface
Pointer for gui interface object.
Definition: pzanalysis.h:74
void Print(const char *name=NULL, std::ostream &out=std::cout, const MatrixOutputFormat=EFormatted) const override
Prints the object data structure.
Definition: pzmatred.cpp:454
TPZSubCompMesh * fMesh
The computational sub mesh.
Definition: pzsmanal.h:29
void CondensedSolution(TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
CondensedSolution: returns the condensed stiffness matrix - ek - and the condensed solution vector - ...
Definition: pzsmanal.cpp:121
Implements the sequence of actions to perform a finite element analysis. Analysis.
Definition: pzanalysis.h:32
virtual void LoadSolution()
Load the solution into the computable grid.
Definition: pzanalysis.cpp:441
Contains TPZMatrixclass which implements full matrix (using column major representation).
Implements a group of computational elements as a mesh and an element. Computational Mesh...
Definition: pzsubcmesh.h:36
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
virtual void SetMatrix(TPZAutoPointer< TPZMatrix< TVar > > Refmat)
Sets a matrix to the current object.
Definition: pzsolve.h:115
TPZFMatrix< STATE > fReferenceSolution
Solution vector.
Definition: pzsmanal.h:24
int ClassId() const override
Define the class id associated with the class.
Definition: pzsmanal.cpp:195
int64_t Index() const
Returns element index of the mesh fELementVec list.
Definition: pzcompel.h:821
virtual int Redim(const int64_t newRows, const int64_t newCols)
Redimensions the matrix reinitializing it with zero.
Definition: pzmatrix.h:289
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
virtual TPZSolver * Clone() const =0
Clones the current object returning a pointer of type TPZSolver.
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
TPZAutoPointer< TPZStructMatrix > fStructMatrix
Structural matrix.
Definition: pzanalysis.h:68
Implements a simple substructuring of a linear system of equations, composed of 4 submatrices...
Definition: pzmatred.h:34
void K11Reduced(TPZFMatrix< TVar > &K11, TPZFMatrix< TVar > &F1)
Computes the K11 reduced .
Definition: pzmatred.cpp:223
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
TPZAutoPointer< TPZMatrix< TVar > > Matrix() const
Returns a pointer to TPZMatrix<>
Definition: pzsolve.h:138
int64_t NumInternalEquations()
Computes the number of internal equations.
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
Contains TPZSubMeshAnalysis class which implements the analysis procedure to computational sub mesh...
TPZFMatrix< STATE > fRhs
Load vector.
Definition: pzanalysis.h:48
virtual void SetCompMesh(TPZCompMesh *mesh, bool mustOptimizeBandwidth)
Set the computational mesh of the analysis.
Definition: pzanalysis.cpp:115
const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
Definition: pzfmatrix.h:566