NeoPZ
pzplasticdiagnostic.cpp
Go to the documentation of this file.
1 //
2 // pzplasticdiagnostic.cpp
3 // PZ
4 //
5 // Created by phil on 3/18/13.
6 // Copyright (c) 2013 __MyCompanyName__. All rights reserved.
7 //
8 
9 #include <iostream>
10 #include "pzplasticdiagnostic.h"
11 #include "pzskylstrmatrix.h"
12 #include "pzskylmat.h"
13 #include "pzcmesh.h"
14 #include "pzcompel.h"
15 
17 {
18 
19 }
20 
22 {
24  TPZFMatrix<STATE> referenceres, solution(fMesh->Solution());
25  int neq = fMesh->NEquations();
26  TPZFMatrix<STATE> rhs(neq,1,0.);
27  solution.Resize(neq, 1);
28  fMesh->Solution().Zero();
29  TPZMatrix<STATE> *matrix = strmat.CreateAssemble(referenceres, 0);
30 // TPZFMatrix<STATE> compareres(solution.Rows(),1,0.);
31 // strmat.Assemble(compareres, 0);
32 // compareres -= referenceres;
33 // std::cout << "Difference between residues " << Norm(compareres) << std::endl;
34 //
35 // int nel = fMesh->NElements();
36 // for (int iel = 0; iel<nel; iel++) {
37 // TPZCompEl *cel = fMesh->ElementVec()[iel];
38 // if (!cel) {
39 // continue;
40 // }
41 // TPZElementMatrix ek,ef, ef2;
42 // cel->CalcStiff(ek,ef);
43 // cel->CalcResidual(ef2);
44 // ef.fMat -= ef2.fMat;
45 // std::cout << "Element " << iel << " norm of difference " << Norm(ef.fMat) << std::endl;
46 // }
47 
48  TPZManVector<STATE,10> residues(10,0.);
49  for (int i=1; i<=10; i++) {
50  TPZFMatrix<STATE> locsol(solution);
51  locsol *= i*1./10.;
52  fMesh->LoadSolution(locsol);
53  strmat.Assemble(rhs, 0);
54  rhs -= referenceres;
55  TPZFMatrix<STATE> result;
56  matrix->MultAdd(locsol, rhs, result,-1.,1.);
57  residues[i-1] = Norm(result);
58  }
59  TPZManVector<STATE> rate(9,0.);
60  for (int i=1; i<10; i++) {
61  rate[i-1] = (log(residues[i]) - log(residues[i-1]))/(log(i+1.)-log(i*1.));
62  }
63  std::cout << "Residues " << residues << std::endl;
64  std::cout << "Global convergence rates " << rate << std::endl;
65  delete matrix;
66 }
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
Contains declaration of TPZCompEl class which defines the interface of a computational element...
virtual void MultAdd(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar alpha=1., const TVar beta=0., const int opt=0) const
It computes z = beta * y + alpha * opt(this)*x but z and x can not overlap in memory.
Definition: pzmatrix.cpp:166
TPZSkylMatrix< REAL > matrix
Definition: numatst.cpp:255
Implements SkyLine Structural Matrices. Structural Matrix.
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
void LoadSolution(const TPZFMatrix< STATE > &sol)
Given the solution of the global system of equations, computes and stores the solution for the restri...
Definition: pzcmesh.cpp:441
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
Contains the TPZSkylineStructMatrix class which implements SkyLine Structural Matrices.
Contains TPZSkyline class which implements a skyline storage format.
Contains declaration of TPZCompMesh class which is a repository for computational elements...
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
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ log
Definition: tfadfunc.h:130
TPZPlasticDiagnostic(TPZCompMesh *cmesh)
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface, unsigned numthreads_assemble, unsigned numthreads_decompose)
Definition: pzstrmatrix.h:100
TPZFMatrix< STATE > & Solution()
Access the solution vector.
Definition: pzcmesh.h:219