NeoPZ
TPZParSkylineStructMatrix.cpp
Go to the documentation of this file.
1 
5 #include "TPZFrontStructMatrix.h"
7 #include "pzskylmatpar.h"
8 #include "pzvec.h"
9 #include "pzstrmatrix.h"
10 #include "pzfstrmatrix.h"
11 
12 #include "pzgmesh.h"
13 #include "pzcmesh.h"
14 #include "pzsubcmesh.h"
15 #include "pzbndcond.h"
16 
17 #include "pzanalysis.h"
18 #include "pzsolve.h"
19 #include "pzstepsolver.h"
20 
21 #include "pzdxmesh.h"
22 #include <fstream>
23 using namespace std;
24 
25 #include "pzelmat.h"
26 #include "TPZFrontStructMatrix.h"
27 
28 
31 }
32 
34 {
36 }
37 
39  return new TPZParSkylineStructMatrix(*this);
40 }
41 
43  int64_t neq = fEquationFilter.NActiveEquations();
44  TPZVec<int64_t> skyline;
45  fMesh->Skyline(skyline);
47  neq = skyline.size();
48  return new TPZSkylParMatrix<STATE>(neq,skyline,fNumThreads);
49 }
51  TPZMatrix<STATE> *mat = Create();
52  rhs.Redim(mat->Rows(),1);
53  Assemble(*mat,rhs,guiInterface);
54  return mat;
55 }
56 
57 #ifndef STATE_COMPLEX
58 #include "pzmat2dlin.h"
59 
61 
62  int order=6;
63 
64  TPZGeoMesh gmesh;
65  TPZCompMesh cmesh(&gmesh);
66  double coordstore[4][3] = {{0.,0.,0.},{1.,0.,0.},{1.,1.,0.},
67  {0.,1.,0.}};
68 
69  int i,j;
70  TPZVec<REAL> coord(3,0.);
71  for(i=0; i<4; i++) {
72  // initializar as coordenadas do no em um vetor
73  for (j=0; j<3; j++) coord[j] = coordstore[i][j];
74 
75  // identificar um espa�o no vetor onde podemos armazenar
76  // este vetor
77 
78  // initializar os dados do n�
79  gmesh.NodeVec ()[i].Initialize (i,coord,gmesh);
80  }
81  int el;
82  //TPZGeoEl *gel;
83  for(el=0; el<1; el++) {
84 
85  // initializar os indices dos n�s
86  TPZVec<int64_t> indices(4);
87  for(i=0; i<4; i++) indices[i] = i;
88  // O proprio construtor vai inserir o elemento na malha
89  int64_t index;
90  /*gel = */gmesh.CreateGeoElement(EQuadrilateral, indices,1,index);
91  }
92  gmesh.BuildConnectivity ();
93 
94  TPZVec<TPZGeoEl *> subel;
95  //gel->Divide(subel);
96 
97 
98  /*
99  cout << "Refinement ";
100  cin >> refine;
101  cout << endl;
102  */
103  //UniformRefine(refine,gmesh);
104 
105 
106  TPZMat2dLin *meumat = new TPZMat2dLin(1);
107  TPZFMatrix<STATE> xk(1,1,1.),xc(1,2,0.),xf(1,1,1.);
108  meumat->SetMaterial (xk,xc,xf);
109  TPZMaterial * meumatptr = meumat;
110  cmesh.InsertMaterialObject(meumatptr);
111 
112  TPZFMatrix<STATE> val1(1,1,0.),val2(1,1,0.);
113  TPZMaterial * bnd = meumat->CreateBC (meumatptr,-4,0,val1,val2);
114  cmesh.InsertMaterialObject(bnd);
115 
116 
117  /*
118  cout << "Interpolation order ";
119  cin >> order;
120  cout << endl;
121  */
122  // TPZCompEl::gOrder = order;
123  cmesh.SetDefaultOrder(order);
124 
125  cmesh.AutoBuild();
126  // cmesh.AdjustBoundaryElements();
127  cmesh.InitializeBlock();
128 
129  ofstream output("outputSkyPar.dat");
130  // ofstream output2("outputNon.dat");
131  cmesh.Print(output);
132  TPZAnalysis an(&cmesh,true,output);
133  // TPZAnalysis an2(&cmesh,output);
134 
135  TPZVec<int> numelconnected(cmesh.NEquations(),0);
136  int64_t ic;
137  //cout << "N�mero de Equa��es -> " << cmesh.NEquations() << endl;
138  //cout.flush();
139 
140  ofstream out("cmeshBlock_out.txt");
141  // cmesh.Print(out);
142  // cmesh.Block().Print("Block",out);
143  for(ic=0; ic<cmesh.ConnectVec().NElements(); ic++) {
144  TPZConnect &cn = cmesh.ConnectVec()[ic];
145  if(cn.HasDependency() || cn.IsCondensed()) continue;
146  int64_t seqn = cn.SequenceNumber();
147  if(seqn < 0) continue;
148  int64_t firsteq = cmesh.Block().Position(seqn);
149  int64_t lasteq = firsteq+cmesh.Block().Size(seqn);
150  int64_t ind;
151  int temp = cmesh.ConnectVec()[ic].NElConnected();
152  for(ind=firsteq;ind<lasteq;ind++) {
153  numelconnected[ind] = temp;//cmesh.ConnectVec()[ic].NElConnected();
154  }
155  }
156  // //cout << "nequations " << numelconnected.NElements();
157  // for(ic=0;ic<numelconnected.NElements(); ic++) //cout << numelconnected[ic] <<' ';
158  // //cout << endl;
159  // //cout.flush();
160 
161  // TPZFrontMatrix<TPZFileEqnStorage, TPZFrontNonSym> *mat = new TPZFrontMatrix<TPZFileEqnStorage, TPZFrontNonSym>(cmesh.NEquations());
162  //TPZFrontMatrix<TPZStackEqnStorage, TPZFrontNonSym> *mat = new TPZFrontMatrix<TPZStackEqnStorage, TPZFrontNonSym>(cmesh.NEquations());
163  //TPZFrontMatrix<TPZStackEqnStorage> *mat = new TPZFrontMatrix<TPZStackEqnStorage>(cmesh.NEquations());
164 
165  const int numthreads = 2;
166  TPZParSkylineStructMatrix mat(&cmesh,numthreads);
167 
168  // TPZFStructMatrix mat2(&cmesh);
169  // mat->SetNumElConnected(numelconnected);
170  //mat = CreateAssemble();
171  /*int threads = 0;
172  cout << "Number of Threads ";
173  cin >> threads;
174  cout << endl;*/
175 
176  //mat.SetNumberOfThreads(threads);
177  // mat.SetNumberOfThreads(1);
178 
179  an.SetStructuralMatrix(mat);
180  // an2.SetStructuralMatrix(mat2);
181 
183  // sol.SetDirect(ELU);
184  sol.SetDirect(ECholesky);
185  // TPZStepSolver sol2;
186  // sol2.SetDirect(ECholesky);
187  // sol.SetDirect(ELU);
188 
189 
190  an.SetSolver(sol);
191  // an2.SetSolver(sol2);
192  // mat->SetNumElConnected(numelconnected);
193  // mat->SetFileName("longhin.bin");
194  // an.Solver().SetDirect(ELU);
195  // mat->FinishWriting();
196  // mat->SetFileName('r',"longhin.bin");
197  // //cout << "******************************************************************************************************AQUI 1" << endl;
198  an.Run(output);
199  an.Print("solution of Skyline solver", output);
200  // //cout << "******************************************************************************************************AQUI 2" << endl;
201  // an2.Run(output2);
202  // an2.Print("solution of frontal solver", output2);
203  /*
204  TPZVec<char *> scalnames(1);
205  scalnames[0] = "state";
206 
207  TPZVec<char *> vecnames(0);
208 
209  TPZDXGraphMesh graph(&cmesh,2,meumat,vecnames,scalnames);
210  ofstream *dxout = new ofstream("poisson.dx");
211  graph.SetOutFile(*dxout);
212  graph.SetResolution(0);
213 
214  //an.DefineGraphMesh(2, scalnames, vecnames, plotfile);
215  //an.Print("FEM SOLUTION ",output);
216  //an.PostProcess(1);
217  int istep = 0,numstep=1;
218 
219  graph.DrawMesh(numstep+1);
220  graph.DrawSolution(0,0);
221 
222  TPZAnalysis an2(&cmesh,output);
223  TPZFMatrix<STATE> *full = new TPZFMatrix(cmesh.NEquations(),cmesh.NEquations(),0.);
224  an2.SetMatrix(full);
225  an2.Solver().SetDirect(ELU);
226  an2.Run(output);
227  an2.Print("solution of full matrix", output);
228 
229  // full->Print("full decomposed matrix");
230  */
231  output.flush();
232  cout.flush();
233  return 0;
234 
235 }
236 
237 #endif
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
int Position(const int block_diagonal) const
Returns the position of first element block dependent on matrix diagonal.
Definition: pzblock.h:177
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
Contains the TPZParSkylineStructMatrix class which defines parallel structural matrix for skyline mat...
void SetStructuralMatrix(TPZAutoPointer< TPZStructMatrix > strmatrix)
Set structural matrix as auto pointer for analysis.
Definition: pzanalysis.cpp:82
virtual TPZStructMatrix * Clone()
void Print(const std::string &name, std::ostream &out)
Print connect and solution information.
Definition: pzanalysis.cpp:447
virtual TPZGeoEl * CreateGeoElement(MElementType type, TPZVec< int64_t > &cornerindexes, int matid, int64_t &index, int reftype=1)
Generic method for creating a geometric element. Putting this method centrally facilitates the modifi...
Definition: pzgmesh.cpp:1296
Contains the TPZFrontStructMatrix class which responsible for a interface among Finite Element Packag...
Contains TPZSkylParMatrix class which implements a skyline storage format to parallelized process...
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
Templated vector implementation.
Defines parallel structural matrix for skyline matrices. Structural Matrix.
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
void FilterSkyline(TPZVec< int64_t > &skyline) const
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
TPZEquationFilter fEquationFilter
Object which will determine which equations will be assembled.
int64_t NElements() const
Access method to query the number of elements of the vector.
Contains the TPZStructMatrixOR class which responsible for a interface among Matrix and Finite Elemen...
virtual TPZMatrix< STATE > * Create()
Contains the TPZFStructMatrix class which implements Full Structural Matrices.
void SetDefaultOrder(int order)
Definition: pzcmesh.h:403
Implements SkyLine Structural Matrices. Structural Matrix.
Refines geometrical mesh (all the elements) num times.
Definition: pzstrmatrix.h:35
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
TPZCompMesh * fMesh
Pointer to the computational mesh from which the matrix will be generated.
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
Implements the sequence of actions to perform a finite element analysis. Analysis.
Definition: pzanalysis.h:32
virtual void Skyline(TPZVec< int64_t > &skyline)
This method computes the skyline of the system of equations.
Definition: pzcmesh.cpp:787
int64_t NActiveEquations() const
Retorna o numero de equacoes ativas do sistema.
TPZParSkylineStructMatrix(TPZCompMesh *, int numthreads)
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
virtual void AutoBuild(const std::set< int > *MaterialIDs)
Creates the computational elements, and the degree of freedom nodes.
Definition: pzcmesh.cpp:308
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
int HasDependency() const
Returns whether exist dependecy information.
Definition: pzconnect.h:292
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
Definition: pzcmesh.h:213
Contains the TPZMat2dLin class which implements a bi-dimensional linear problem.
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
Definition: pzcmesh.h:198
Contains declaration of TPZCompMesh class which is a repository for computational elements...
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
void SetMaterial(TPZFMatrix< STATE > &xkin, TPZFMatrix< STATE > &xcin, TPZFMatrix< STATE > &xfin)
Definition: pzmat2dlin.h:44
virtual void Assemble(TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface) override
Assemble the global system of equations into the matrix which has already been created.
Definition: pzstrmatrix.cpp:80
virtual void Run(std::ostream &out=std::cout)
Calls the appropriate sequence of methods to build a solution or a time stepping sequence.
Definition: pzanalysis.cpp:920
void BuildConnectivity()
Build the connectivity of the grid.
Definition: pzgmesh.cpp:967
virtual TPZBndCond * CreateBC(TPZMaterial *reference, int id, int typ, TPZFMatrix< STATE > &val1, TPZFMatrix< STATE > &val2)
Creates an object TPZBndCond derived of TPZMaterial.
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
Implements a skyline storage format to parallelized process. Matrix.
Definition: pzskylmatpar.h:35
int InsertMaterialObject(TPZMaterial *mat)
Insert a material object in the datastructure.
Definition: pzcmesh.cpp:287
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
Implements a bi-dimensional linear problem.
Definition: pzmat2dlin.h:22
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
int Size(const int block_diagonal) const
Returns block dimension.
Definition: pzblock.h:171
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
Contains TPZStepSolver class which defines step solvers class.
void SetDirect(const DecomposeType decomp)
Contains the TPZDXGraphMesh class which implements the interface of the graphmesh to the OpenDX graph...
void InitializeBlock()
Resequence the block object, remove unconnected connect objects and reset the dimension of the soluti...
Definition: pzcmesh.cpp:391
bool IsCondensed() const
Access method to return the indication whether the connect is condensed or not.
Definition: pzconnect.h:223
virtual void Print(std::ostream &out=std::cout) const
Prints mesh data.
Definition: pzcmesh.cpp:236