23 static LoggerPtr logger(Logger::getLogger(
"pz.converge"));
31 fNewtonEps(1e-9), fNewtonMaxIter(10),
32 fTimeIntEps(1e-8), fTimeIntMaxIter(100),
33 fEvolCFL(0), fpBlockDiag(NULL),fHasFrontalPreconditioner(0)
71 REAL initEpsilon = epsilon;
84 epsilon = initEpsilon;
88 if(epsilon > initEpsilon)
112 #ifdef RESTART_ZEROED 160 PZError <<
"TPZEulerAnalysis::Assemble Error: No Computational Mesh\n";
167 PZError <<
"TPZEulerAnalysis::Assemble Error: No Structural Matrix\n";
174 PZError <<
"TPZEulerAnalysis::Assemble Error: No Solver\n";
193 PZError <<
"TPZEulerAnalysis::Assemble Error: No Structural Matrix\n";
199 pTangentMatrix->Zero();
240 residual->
Redim(numeq,1);
269 while(i < fNewtonMaxIter && epsilon >
fNewtonEps)
276 cout <<
"\tEntry NonLinEpsilon:" << epsilon << endl;
281 if(
Solve(res, &residual, delSol) == 0)
return 0;
289 cout <<
"\tNonLinEpsilon:" << epsilon << endl;
295 std::stringstream sout;
296 sout <<
"Numero de iteracoes de Newton " << i;
302 if(epsilon > fNewtonEps)
return 0;
309 scalar[0] =
"density";
310 scalar[1] =
"pressure";
311 scalar[2] =
"normvelocity";
321 std::set<int> matids;
322 matids.insert(mat->
Id());
342 out <<
"\nBeginning time integration";
344 time_t startTime_t = time(NULL);
351 REAL epsilon, lastEpsilon=0;
356 #ifdef RESTART_ZEROED 371 out <<
"iter\ttime\teps(dU/dt)\tNewtonEps=\tnNewtonIter\n";
373 while(i < fTimeIntMaxIter && epsilon >
fTimeIntEps)
378 graph->
Out().flush();
380 AccumTime += nextTimeStep;
386 RunNewton(epsilon_Newton, numIter_Newton);
403 CFLControl(lastEpsilon, epsilon, epsilon_Newton, nextTimeStep);
406 if(logger->isDebugEnabled())
408 std::stringstream sout;
409 sout <<
"iteration " << i <<
"Du/Dt " << epsilon <<
" Total Newton " <<
fTotalNewton;
418 <<
"\t" << epsilon_Newton
419 <<
"\t" << numIter_Newton;
422 <<
"\ttime:" << AccumTime
423 <<
"\t eps(dU/dt)=" << epsilon
424 <<
"\t |NewtonEps=" << epsilon_Newton
425 <<
"\t nIter=" << numIter_Newton << endl;
431 std::stringstream sout;
432 sout <<
"Total number of newton iterations " << this->
fTotalNewton;
442 graph->
Out().flush();
446 time_t endTime_t = time(NULL);
448 out <<
"\nElapsed time in seconds: " << (endTime_t - startTime_t) << endl;
450 cout <<
"\nElapsed time in seconds: " << (endTime_t - startTime_t) << endl;
458 if((lastEpsilon>0. && epsilon>0.) &&
fEvolCFL >= 1)
461 timeStep *= lastEpsilon/epsilon;
465 if(epsilon_Newton < fNewtonEps && fEvolCFL >= 2)
477 lastEpsilon = epsilon;
519 REAL smallestincr = 1.e-3;
528 while (
fabs(incr) > smallestincr) {
530 solution += (direction *(STATE)dist);
539 error = 2*preverr+2.;
541 if (error < preverr &&
fabs(dist - 1.0) < 1.e-9) {
544 else if (error < preverr && dist < 1.00 && dist > 0.) {
557 cout <<
"TPBNonLinearAnalysis improper search direction\n";
558 direction *= smallestincr;
562 if (
fabs(dist - 1.) > smallestincr) {
568 if(dist > 0.)
return 1;
588 for(iel=0; iel < nelem; iel++) {
void CompareRhs()
Trying difference between two times.
int64_t NElements() const
Number of computational elements allocated.
TPZMatrixSolver< STATE > * fSolver
Type of solver to be applied.
REAL fTimeIntEps
Stop criteria for time integration loops.
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
REAL ComputeTimeStep()
Computes the current time step for the mesh.
virtual void AssembleRhs()
Assembles the right hand side vector.
void ResetMatrix() override
Resets current object.
virtual void SetFileName(const std::string &filename)
Sets the name of the output file.
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.
void SetStructuralMatrix(TPZAutoPointer< TPZStructMatrix > strmatrix)
Set structural matrix as auto pointer for analysis.
virtual void Run(std::ostream &out, const std::string &dxout, int dxRes)
See declaration in the base class.
Implements Block Diagonal Structural Matrices. Structural Matrix.
TPZFMatrix< STATE > fSolution
Solution vector.
TPZFMatrix< STATE > fRhsLast
Vector to hold the contribution of last state to the rhs.
virtual void Assemble()
Assembles the stiffness matrix.
This class is used as an exception thrown on an outofrange condition.
void SetPreconditioner(TPZSolver< TVar > &solve)
Define the preconditioner as a solver object.
Implements the interface of the graphmesh to the OpenDX graphics package. Post processing.
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
void UpdateSolAndRhs(TPZFMatrix< STATE > &deltaSol, REAL &epsilon)
Adds deltaSol to the last solution and stores it as the current solution, preparing it to contribute ...
void ScaleCFL(REAL scale)
Scales the CFL of all materials.
void WriteCMesh(const char *str)
Writes the computational mesh onto disk.
TPZFNMatrix< 1000, STATE > fMat
Pointer to a blocked matrix object.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Defines step solvers class. Solver.
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
TPZCompMesh * fCompMesh
Computational mesh.
int LineSearch(REAL &residual, TPZFMatrix< STATE > &sol0, TPZFMatrix< STATE > &dir)
This method will search for the solution which minimizes the residual.
TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
Returns a pointer to TPZMatrix.
void OpenWrite(const std::string &fileName)
void BuildFromMatrix(TPZMatrix< TVar > &matrix)
Builds a block from matrix.
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element stifness matrix and right hand side.
TPZCompMesh * Mesh() const
Returns the pointer to the computational mesh.
virtual void Solve(const TPZFMatrix< TVar > &F, TPZFMatrix< TVar > &result, TPZFMatrix< TVar > *residual=0)=0
Solves the system of linear equations.
virtual int Dimension() const =0
Returns the integrable dimension of the material.
int RunNewton(REAL &epsilon, int &numIter)
Implements the Newton's method.
void SetContributionTime(TPZContributeTime time)
Informs the Analysis class the time at which the current solution in the computational mesh belongs ...
int fTotalNewton
Total number of newton iterations during this run.
void BufferLastStateAssemble()
Buffers the assemblage of the rhs with respect to the last state.
REAL EvaluateFluxEpsilon()
Evaluates the flux part of the residual for convergence check.
Implements a chunk vector with free store administration. Utility.
int fEvolCFL
Indicates whether the CFL is to evolute or not.
REAL fNewtonEps
Stop criteria for the Newton loops.
void SetEvolCFL(int EvolCFL)
Indicates whether the CFL is to evolute or not.
TPZMatrixSolver< STATE > & Solver()
Get the solver matrix.
virtual TPZMatrix< STATE > * Create() override
void SetGMResBlock(REAL tol, int numiter, int numvec)
Set to solve with GMRes algorithm for block diagonal matrix.
Contains the TPZFStructMatrix class which implements Full Structural Matrices.
Contains the TPZBlockDiagonalStructMatrix class which implements Block Diagonal Structural Matrices...
This abstract class defines the behaviour which each derived class needs to implement.
void SetResolution(int res)
Sets resolution.
Computational mesh with additional data for CFD problems. Computational Mesh.
void SetFrontalSolver()
Set to solve with Frontal method.
TPZMaterial * GetFlowMaterial()
Returns the first flow material in the mesh.
int Zero() override
Makes Zero all the elements.
void LoadSolution(const TPZFMatrix< STATE > &sol)
Given the solution of the global system of equations, computes and stores the solution for the restri...
void SetTimeIntCriteria(REAL epsilon, int maxIter)
Settings for the time integration method.
Implements the sequence of actions to perform a finite element analysis. Analysis.
void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
virtual void DrawSolution(TPZBlock< REAL > &Sol)
Draw solution as dx file.
Implements reading from and writing to an ascii file. Persistency.
int fNewtonMaxIter
Maxime iterations for iterative Newton loops.
void SetContributionTime(TPZContributeTime time)
Informs the time at which the current solution in the computational mesh belongs, so that the materia...
Contains TPZEulerAnalysis class which implements an analysis procedure for compressible Euler flow si...
void SetGMResFront(REAL tol, int numiter, int numvectors)
Set to solve with GMRes algorithm.
TPZGeoMesh * fGeoMesh
Geometric Mesh.
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
#define DebugStop()
Returns a message to user put a breakpoint in.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
void SetBlockDiagonalPrecond(TPZBlockDiagonal< STATE > *blockDiag)
Informs a block diagonal to be used as preconditioning.
virtual void SetMatrix(TPZAutoPointer< TPZMatrix< TVar > > Refmat)
Sets a matrix to the current object.
int64_t Rows() const
Returns number of rows.
void SetResidualType(TPZResidualType type)
Sets the kind of residual to be computed.
Responsible for a interface among Finite Element Package and Matrices package to frontal method...
~TPZEulerAnalysis()
Simple destructor.
TPZFlowCompMesh * fFlowCompMesh
Stores a pointer to the computational flow mesh.
Contains declaration of TPZCompelDisc class which implements a computational element for discontinuou...
REAL ComputeTimeStep()
Defines the time step for each material in the mesh.
void UpdateHistory()
After a call to UpdateSolution, this method shifts the history in one solution, so that the current s...
void SetFlowforcingFunction(TPZAutoPointer< TPZFunction< STATE > > fp)
Sets the forcing funtion for all fluid materials in the mesh.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
virtual void DrawMesh(int numcases)
Draw mesh as dx file.
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
TPZDXGraphMesh * PrepareDXMesh(const std::string &dxout, int dxRes)
Prepares the DX graph mesh.
Contains the TPBSpStructMatrix class which assembles on the pair equations.
int Zero() override
Zeroes all the elements of the matrix.
REAL dist(TPZVec< T1 > &vec1, TPZVec< T1 > &vec2)
TPZAutoPointer< TPZStructMatrix > fStructMatrix
Structural matrix.
virtual void CalcResidual(TPZElementMatrix &ef)
Computes the element right hand side.
void CFLControl(REAL &lastEpsilon, REAL &epsilon, REAL &epsilon_Newton, REAL &timeStep)
Evaluates the CFL control based on the newest residual norm (epsilon) and last residual norm (lastEps...
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
TPZAutoPointer< TPZMatrix< TVar > > Matrix() const
Returns a pointer to TPZMatrix<>
int fHasFrontalPreconditioner
Indication if a frontal matrix is being used as a preconditioner.
virtual void Solve()
Invert the stiffness matrix.
Implements Sparse Structural Matrices. Structural Matrix.
int fTimeIntMaxIter
Maxime iterations for iterative time integration loops.
Contains the TPZOutofRange class.
void SetDirect(const DecomposeType decomp)
TPZBlockDiagonal< STATE > * fpBlockDiag
Preconditioner.
TPZFMatrix< STATE > fRhs
Load vector.
void SetLastState()
Sets the solution vector to be the one representing the Current State (Wn) or the last explicit solut...
Is a structural matrix with parallel techniques included. Structural Matrix Frontal.
void AssembleBlockDiagonal(TPZBlockDiagonal< STATE > &block)
Defines the interface of a computational element. Computational Element.
TPZContributeTime
Indicates which term is put in the right hand side and tangent matrix.
void SetNewtonCriteria(REAL epsilon, int maxIter)
Settings for the Newton's method.
TPZEulerAnalysis()
Default constructor.
Contains the TPZParFrontStructMatrix class which is a structural matrix with parallel techniques incl...
void SetAdvancedState()
Sets the solution vector to be the one representing the Advanced State (Wn+1) or the advanced implici...
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
#define PZError
Defines the output device to error messages and the DebugStop() function.
void SetGMRES(const int64_t numiterations, const int numvectors, const TPZMatrixSolver< TVar > &pre, const REAL tol, const int64_t FromCurrent)
This class implements a reference counter mechanism to administer a dynamically allocated object...