46 cout <<
"TPZMGAnalysis::AppendMesh can only be called after solving the coarse mesh\n";
70 int nvar = mesh->
MaterialVec().begin()->second->NStateVariables();
74 if(!prec) prec =
fSolvers[nmeshes-1];
87 s4.
SetCG(200,s3,1.e-6,1);
94 cout <<
"TPZMGAnalysis cannot delete the root mesh, sorry\n";
112 int dim = fine->
MaterialVec().begin()->second->Dimension();
123 for(el=0; el<
numel; el++) {
124 cel = elementvec[el];
130 if(gelside.Dimension() != dim)
continue;
134 cout <<
"TPZMGAnalsysis::BuildTransferMatrix element " << el <<
" found no corresponding element\n";
141 gelside.SideTransform3(gellarge,transform);
142 int index = cellarge->
Index();
144 ervec[index] +=
ElementError(cint,cintlarge,transform,
f,truerror);
145 if(
f) truervec[index] += truerror;
156 int locmatsize = fine->
NShapeF();
157 int cormatsize = coarse->
NShapeF();
161 STATE loclocmatstore[500] = {0.},loccormatstore[500] = {0.};
189 int maxorder = interpolation[0];
190 for(dim=0; dim<interpolation.
NElements(); dim++) {
191 maxorder = interpolation[dim] < maxorder ? maxorder : interpolation[dim];
199 REAL locphistore[50]={0.},locdphistore[150]={0.};
201 TPZFMatrix<REAL> locdphi(dimension,locmatsize,locdphistore,150),locdphix(dimension,locmatsize);
205 REAL corphistore[50]={0.},cordphistore[150]={0.};
207 TPZFMatrix<REAL> cordphi(dimension,cormatsize,cordphistore,150), cordphix(dimension,cormatsize);
211 REAL jacobianstore[9],
214 coarse_int_point(dimension);
215 TPZFMatrix<REAL> jacfine(dimension,dimension,jacobianstore,9),jacinvfine(dimension,dimension);
218 TPZFMatrix<REAL> jaccoarse(dimension,dimension),jacinvcoarse(dimension,dimension);
223 int numintpoints = intrule->
NPoints();
229 for(
int int_ind = 0; int_ind < numintpoints; ++int_ind) {
231 intrule->
Point(int_ind,int_point,weight);
233 fine->
Reference()->
Jacobian( int_point, jacfine , axesfine, jacdetfine, jacinvfine);
235 if(
f)
f(xfine,truesol,truedsol);
236 fine->
Shape(int_point,locphi,locdphi);
237 tr.
Apply(int_point,coarse_int_point);
238 coarse->
Shape(coarse_int_point,corphi,cordphi);
239 coarse->
Reference()->
Jacobian( coarse_int_point,jaccoarse,axescoarse, jacdetcoarse, jacinvcoarse);
240 coarse->
Reference()->
X(coarse_int_point,xcoarse);
241 REAL
dist = (xfine[0]-xcoarse[0])*(xfine[0]-xcoarse[0])+(xfine[1]-xcoarse[1])*(xfine[1]-xcoarse[1])+(xfine[2]-xcoarse[2])*(xfine[2]-xcoarse[2]);
242 if(dist > 1.e-6) cout <<
"TPZMGAnalysis::ElementError transformation between fine and coarse is wrong\n";
246 for(k=0; k<3; k++) axesinner(i,j) += axesfine(i,k)*axescoarse(j,k);
249 if(
fabs(axesinner(0,0)-1.) > 1.e-6 ||
fabs(axesinner(1,1)-1.) > 1.e-6 ||
fabs(axesinner(0,1)) > 1.e-6 ||
fabs(axesinner(1,0)) > 1.e-6) {
250 cout <<
"TPZMGAnalysis axesinner is not identify?\n";
252 weight *=
fabs(jacdetfine);
262 for(ieq=0; ieq<locmatsize; ieq++) locdphix(d,ieq) = locdphi(d,ieq)*(1./jacdetfine);
263 for(ieq=0; ieq<cormatsize; ieq++) cordphix(d,ieq) = cordphi(d,ieq)*(axesinner(0,0)/jacdetcoarse);
267 for(ieq = 0; ieq < locmatsize; ieq++) {
268 locdphix(0,ieq) = jacinvfine(0,0)*locdphi(0,ieq) + jacinvfine(1,0)*locdphi(1,ieq);
269 locdphix(1,ieq) = jacinvfine(0,1)*locdphi(0,ieq) + jacinvfine(1,1)*locdphi(1,ieq);
271 tmp[0] = locdphix(0,ieq)*axesfine(0,0)+locdphix(1,ieq)*axesfine(1,0);
272 tmp[1] = locdphix(0,ieq)*axesfine(0,1)+locdphix(1,ieq)*axesfine(1,1);
273 locdphix(0,ieq) = tmp[0];
274 locdphix(1,ieq) = tmp[1];
276 for(ieq = 0; ieq < cormatsize; ieq++) {
277 cordphix(0,ieq) = jacinvcoarse(0,0)*cordphi(0,ieq) + jacinvcoarse(1,0)*cordphi(1,ieq);
278 cordphix(1,ieq) = jacinvcoarse(0,1)*cordphi(0,ieq) + jacinvcoarse(1,1)*cordphi(1,ieq);
280 tmp[0] = cordphix(0,ieq)*axescoarse(0,0)+cordphix(1,ieq)*axescoarse(1,0);
281 tmp[1] = cordphix(0,ieq)*axescoarse(0,1)+cordphix(1,ieq)*axescoarse(1,1);
282 cordphix(0,ieq) = tmp[0];
283 cordphix(1,ieq) = tmp[1];
287 for(ieq = 0; ieq < locmatsize; ieq++) {
288 locdphix(0,ieq) = jacinvfine(0,0)*locdphi(0,ieq) + jacinvfine(0,1)*locdphi(1,ieq) + jacinvfine(0,2)*locdphi(2,ieq);
289 locdphix(1,ieq) = jacinvfine(1,0)*locdphi(0,ieq) + jacinvfine(1,1)*locdphi(1,ieq) + jacinvfine(1,2)*locdphi(2,ieq);
290 locdphix(2,ieq) = jacinvfine(2,0)*locdphi(0,ieq) + jacinvfine(2,1)*locdphi(1,ieq) + jacinvfine(2,2)*locdphi(2,ieq);
292 for(ieq = 0; ieq < cormatsize; ieq++) {
293 cordphix(0,ieq) = jacinvcoarse(0,0)*cordphi(0,ieq) + jacinvcoarse(0,1)*cordphi(1,ieq) + jacinvcoarse(0,2)*cordphi(2,ieq);
294 cordphix(1,ieq) = jacinvcoarse(1,0)*cordphi(0,ieq) + jacinvcoarse(1,1)*cordphi(1,ieq) + jacinvcoarse(1,2)*cordphi(2,ieq);
295 cordphix(2,ieq) = jacinvcoarse(2,0)*cordphi(0,ieq) + jacinvcoarse(2,1)*cordphi(1,ieq) + jacinvcoarse(2,2)*cordphi(2,ieq);
297 tmp[0] = cordphix(0,ieq)*axesinner(0,0)+cordphix(1,ieq)*axesinner(0,1)+cordphix(2,ieq)*axesinner(0,2);
298 tmp[1] = cordphix(0,ieq)*axesinner(1,0)+cordphix(1,ieq)*axesinner(1,1)+cordphix(2,ieq)*axesinner(1,2);
299 tmp[2] = cordphix(0,ieq)*axesinner(2,0)+cordphix(1,ieq)*axesinner(2,1)+cordphix(2,ieq)*axesinner(2,2);
300 cordphix(0,ieq) = tmp[0];
301 cordphix(1,ieq) = tmp[1];
302 cordphix(2,ieq) = tmp[2];
306 PZError <<
"pzintel.c please implement the " << dim <<
"d Jacobian and inverse\n";
314 for(in=0; in<locnod; in++) {
317 int dfvar = locblock.
Size(dfseq);
320 for(
int jn=0; jn<dfvar; jn++) {
321 locsol[iv%numdof] += (STATE)locphi(iv/numdof,0)*locsolmesh(pos+jn,0);
323 locdsol(d,iv%numdof) += (STATE)locdphix(d,iv/numdof)*locsolmesh(pos+jn,0);
330 for(in=0; in<cornod; in++) {
333 int dfvar = corblock.
Size(dfseq);
335 for(
int jn=0; jn<dfvar; jn++) {
336 corsol[iv%numdof] += (STATE)corphi(iv/numdof,0)*corsolmesh(pos+jn,0);
338 cordsol(d,iv%numdof) += (STATE)cordphix(d,iv/numdof)*corsolmesh(pos+jn,0);
343 for(jn=0; jn<numdof; jn++) {
346 for(d=0; d<dim; d++) {
347 error +=
fabs((locdsol(d,jn)-cordsol(d,jn))*(locdsol(d,jn)-cordsol(d,jn))*(STATE)weight);
348 if(
f) truerror +=
fabs((cordsol(d,jn)-truedsol(d,jn))*(cordsol(d,jn)-truedsol(d,jn))*(STATE)weight);
387 REAL normres =
Norm(residual);
388 if(normrhs*1.e-6 >= normres) {
389 cout <<
"TPZMGAnalysis::Solve no need for iterations normrhs = " << normrhs <<
" normres = " << normres << endl;
400 if(stepsolve) stepsolve->
SetTolerance(1.e-6*normrhs/normres);
401 cout <<
"TPZMGAnalysis::Run res : " <<
Norm(residual) <<
" neq " << numeq << endl;
402 solve->
Solve(residual, delu);
418 cout <<
"TPZMGAnalysis::UniformlyRefineMesh encountered no geometric mesh\n";
426 for(el=0; el<nelem; el++) {
431 cout <<
"TPZMGAnalysis::UniformlyRefineMesh encountered a non interpolated element\n";
439 cout <<
"TPZMGAnalysis::UniformlyRefineMesh encountered an element without geometric reference\n";
447 for(isub=0; isub<
nsub; isub++) {
450 if(withP) csint->
PRefine(porder+1);
460 if(nsol != nmesh || nsol < 2) {
461 cout <<
"TPZMGAnalysis cannot compute the errors\n";
int64_t NElements() const
Number of computational elements allocated.
TPZMatrixSolver< STATE > * fSolver
Type of solver to be applied.
virtual void GetOrder(TPZVec< int > &ord) const =0
Gets the order of the integration rule for each dimension of the master element.
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Contains the TPZFrontSym class which implements decomposition process of the frontal matrix (case sym...
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_ expr_ expr_ expr_ expr_ fabs
Contains the TPZMGSolver class which represents a solution process in three steps.
Contains the TPZInt1d, TPZIntTriang, TPZIntQuad, TPZIntCube3D, TPZIntTetra3D, TPZIntPyram3D and TPZIn...
const int64_t numel
Number of elements to test.
int Position(const int block_diagonal) const
Returns the position of first element block dependent on matrix diagonal.
virtual int NPoints() const =0
Returns number of points for the cubature rule related.
Implements computational element and a side. Computational Element.
virtual void Residual(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &rhs, TPZFMatrix< TVar > &res)
Computes res = rhs - this * x.
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
virtual void Solve()
Invert the stiffness matrix.
void ShareMatrix(TPZMatrixSolver< TVar > &other)
Shares the current matrix with another object of same type.
void SetStructuralMatrix(TPZAutoPointer< TPZStructMatrix > strmatrix)
Set structural matrix as auto pointer for analysis.
Implements Block Diagonal Structural Matrices. Structural Matrix.
virtual int Dimension() const override=0
Returns the dimension of the element.
virtual TPZSolver< TVar > * Clone() const override
Clones the current object returning a pointer of type TPZSolver.
void OptimizeBandwidth()
Sets the computer connection block number from the graphical connections block number otimization...
TPZFMatrix< STATE > fSolution
Solution vector.
Contains the TPZFrontStructMatrix class which responsible for a interface among Finite Element Packag...
clarg::argInt nsub("-nsub", "number of substructs", 4)
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
TPZGeoElSide Father2() const
returns the father/side pair which contains the set of points associated with this/side ...
Defines step solvers class. Solver.
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
TPZCompMesh * fCompMesh
Computational mesh.
virtual TPZMatrix< STATE > * Create() override
Creates a sparse blockdiagonal matrix, overlapping should be assumed.
static TPZCompMesh * UniformlyRefineMesh(TPZCompMesh *mesh, bool withP=false)
Proceeds the uniformly h-p refinement of mesh.
Contains the TPZFrontNonSym class which implements storage and decomposition process of the frontal m...
virtual void Solve(const TPZFMatrix< TVar > &F, TPZFMatrix< TVar > &result, TPZFMatrix< TVar > *residual=0)=0
Solves the system of linear equations.
virtual int NStateVariables() const =0
Returns the number of state variables associated with the material.
Declarates the TPZBlock<REAL>class which implements block matrices.
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
void AppendSolver(TPZMatrixSolver< TVar > &solve)
virtual TPZSolver< TVar > * Clone() const override
Clones the current object returning a pointer of type TPZSolver.
int64_t NElements() const
Access method to query the number of elements of the vector.
REAL val(STATE &number)
Returns value of the variable.
Implements a chunk vector with free store administration. Utility.
AutoPointerMutexArrayInit tmp
virtual const TPZIntPoints & GetIntegrationRule() const override=0
Returns a reference to an integration rule suitable for integrating the interior of the element...
virtual void Divide(TPZVec< TPZGeoEl *> &pv)
Divides the element and puts the resulting elements in the vector.
Contains TPZBlockDiagonal class which defines block diagonal matrices.
TPZStack< TPZFMatrix< STATE > * > fSolutions
Contains the meshes solutions.
std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &result, TPZFMatrix< STATE > &deriv)> fExact
Pointer to Exact solution function, it is necessary to calculating errors.
Contains the TPZTransfer class which implements a rectangular sparse block matrix.
void LoadReferences()
Map this grid in the geometric grid.
TPZStack< TPZMatrixSolver< STATE > * > fPrecondition
Contains the preconditioner of the solution method if the solution method is a krylov method...
int NShapeF() const override
Returns the total number of shapefunctions.
TPZCompMesh * PopMesh()
Pop the last mesh of the meshes vector.
Implements SkyLine Structural Matrices. Structural Matrix.
static void MeshError(TPZCompMesh *fine, TPZCompMesh *coarse, TPZVec< REAL > &ervec, void(*f)(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv), TPZVec< REAL > &truervec)
Evaluates the error between aproximation of coarse and fine meshes.
Contains the TPZBlockDiagonalStructMatrix class which implements Block Diagonal Structural Matrices...
TPZMGAnalysis(TPZCompMesh *)
Creates an object multigrid analysis giving a computational mesh.
void BuildTransferMatrix(TPZCompMesh &coarsemesh, TPZTransfer< STATE > &transfer)
Builds the transfer matrix from the current grid to the coarse grid.
virtual void Shape(TPZVec< REAL > &qsi, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphidxi)=0
Computes the shape function set at the point x.
virtual TPZMaterial * Material() const
Identify the material object associated with the element.
TPZCompEl * CreateCompEl(TPZGeoEl *gel, int64_t &index)
Create a computational element based on the geometric element.
int Zero() override
Makes Zero all the elements.
virtual ~TPZMGAnalysis()
Destructor.
virtual void GetInterpolationOrder(TPZVec< int > &ord)=0
Identifies the interpolation order of all connects of the element different from the corner connects...
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
void LoadSolution(const TPZFMatrix< STATE > &sol)
Given the solution of the global system of equations, computes and stores the solution for the restri...
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
void SetCG(const int64_t numiterations, const TPZMatrixSolver< TVar > &pre, const REAL tol, const int64_t FromCurrent)
Implements the sequence of actions to perform a finite element analysis. Analysis.
void Push(const T object)
Pushes a copy of the object on the stack.
void AppendMesh(TPZCompMesh *mesh)
Append a mesh to the meshes vector.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
void ComputeError(TPZVec< REAL > &error)
Loads the last two solutions and call the error between these two aproximations.
virtual void SetOrder(TPZVec< int > &ord, int type=0)=0
Sets the order of the cubature rule.
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Contains the TPZSkylineStructMatrix class which implements SkyLine Structural Matrices.
void Jacobian(TPZVec< REAL > &qsi, TPZFMatrix< REAL > &jac, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv) const
Compute a decomposition of the gradient of the mapping function, as a rotation matrix (Jacobian) and ...
int64_t Rows() const
Returns number of rows.
Contains TPZSequenceSolver class which defines sequence solvers.
void SetTolerance(REAL tol)
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
Represents a solution process in three steps: transfer of the residual, execute a solver on the coars...
int Exists() const
Verifies if the object is non null (initialized)
Contains TPZSkyline class which implements a skyline storage format.
int64_t Index() const
Returns element index of the mesh fELementVec list.
virtual int NConnects() const override=0
Returns the number of connect objects of the element.
virtual int PreferredSideOrder(int iside)=0
Returns the preferred order of the polynomial along side iside.
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.
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
std::map< int,TPZMaterial *> & MaterialVec()
Returns a reference to the material pointers vector.
void TransferSolution(const TPZFMatrix< TVar > &coarsesol, TPZFMatrix< TVar > &finesol)
Will transfer the solution, taking into acount there may be more than one TVar variable.
virtual TPZSolver * Clone() const =0
Clones the current object returning a pointer of type TPZSolver.
T Pop()
Retrieve an object from the stack.
TPZCompEl * Element() const
Gives a pointer to the reference computational element.
REAL dist(TPZVec< T1 > &vec1, TPZVec< T1 > &vec2)
This class implements a very simple interface from PZ kernel to GUI. Module: Common.
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
virtual void X(TPZVec< REAL > &qsi, TPZVec< REAL > &result) const =0
Return the coordinate in real space of the point coordinate in the master element space...
TPZCompElSide Reference() const
Returns a pointer to the elementside referenced by the geometric elementside.
TPZStack< TPZCompMesh *> fMeshes
Contains the computational meshes of one cycle.
This class implements a geometric mesh for the pz environment. Geometry.
Defines sequence solvers. Solver.
int Dimension() const
the dimension associated with the element/side
Implements computational mesh. Computational Mesh.
int Size(const int block_diagonal) const
Returns block dimension.
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
clarg::argBool bd("-bd", "binary dump. Dump file format == binary.", false)
TPZAutoPointer< TPZMatrix< TVar > > Matrix() const
Returns a pointer to TPZMatrix<>
void PRefine(int order) override
Changes the interpolation order of a side. Updates all constraints and block sizes ...
Contains declaration of TPZInterpolatedElement class which implements computational element of the in...
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
Contains TPZStepSolver class which defines step solvers class.
void CopyMaterials(TPZCompMesh &mesh) const
Copies the materials of this mesh to the given mesh.
TPZStack< TPZMatrixSolver< STATE > * > fSolvers
Contains the solution method applied to the mesh.
int64_t NElements() const
Returns the number of elements of the vector.
virtual void Solve()
Uses fSolver object to apply a solution algorithm.
virtual TPZIntPoints * Clone() const =0
Make a clone of the related cubature rule.
void SetDirect(const DecomposeType decomp)
clarg::argInt porder("-porder", "polinomial order", 1)
Implements rectangular matrix which extends a solution vector of the coarse mesh to a solution vector...
TPZFMatrix< STATE > fRhs
Load vector.
static REAL ElementError(TPZInterpolatedElement *fine, TPZInterpolatedElement *coarse, TPZTransform<> &tr, void(*f)(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv), REAL &truerror)
Calculates an element error based on two aproximations.
void ResetReference()
Resets all load references in elements and nodes.
void AssembleBlockDiagonal(TPZBlockDiagonal< STATE > &block)
Defines the interface of a computational element. Computational Element.
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface, unsigned numthreads_assemble, unsigned numthreads_decompose)
TPZFMatrix< STATE > & Solution()
Access the solution vector.
Contains TPZMGAnalysis class which implements multigrid analysis.
Implements computational element based on an interpolation space. Computational Element.
virtual void Point(int i, TPZVec< REAL > &pos, REAL &w) const =0
Returns i-th point at master element and related weight.
#define PZError
Defines the output device to error messages and the DebugStop() function.
This class implements a reference counter mechanism to administer a dynamically allocated object...