32 fSingular(),fTotalError(0.),fAdmissibleError(0.0),fEtaAdmissible(0.05),fNIterations(4) {}
39 std::ofstream
arq(
"Param.dat");
42 cout <<
"\n\nIteration 1\n";
43 out <<
"\n Iteration 1\n";
48 bool store_error =
false;
51 arq <<
"\n iter = " << iter << endl;
58 PZError << endl <<
"TPZAnalysisError::hp_Adaptive_Mesh_Design - At least 3 norms are expected." << endl;
61 out <<
" - Error Energy Norm : " << errors[0] << endl;
62 out <<
" - FE Sol Energy Norm : " << errors[1] << endl;
63 out <<
" - Ex Sol Energy Norm : " << errors[2] << endl;
65 for(
int ier = 3; ier < errors.
NElements(); ier++)
66 out <<
"Other norms : " << errors[ier] << endl;
68 out <<
" - Eta Admissible : " << CurrentEtaAdmissible << endl;
70 out <<
" - Eta Reached : " << errors[0]/errors[2] << endl;
77 HPAdapt(CurrentEtaAdmissible,out);
87 cout <<
"\n\nIteration " << (iter+1) << endl;
88 out <<
"\n Iteration " << (iter+1) << endl;
101 PZError << endl <<
"TPZAnalysisError::hp_Adaptive_Mesh_Design - At least 3 norms are expected." << endl;
105 out <<
" - Error Energy Norm : " << errors[0] << endl;
106 out <<
" - FE Sol Energy Norm : " << errors[1] << endl;
107 out <<
" - Ex Sol Energy Norm : " << errors[2] << endl;
109 for(
int ier = 3; ier < errors.
NElements(); ier++)
110 out <<
"Other norms : " << errors[ier] << endl;
112 out <<
" - Eta Admissible : " << CurrentEtaAdmissible << endl;
114 out <<
" - Eta Reached : " << errors[0]/errors[2] << endl;
120 bool store_error =
false;
123 solution[0] =
"Solution";
126 std::stringstream plotfile;
128 plotfile <<
'0' << iter;
135 solution[0] =
"POrder";
136 solution[1] =
"Error";
138 std::stringstream plotfile;
140 plotfile <<
'0' << iter;
154 REAL hn = 1./
pow(csi,1./singularity_strength);
156 REAL NcReal =
log( 1.+(1./hn - 1.)*(Q - 1.) )/
log(Q);
158 while(REAL(Nc) < (NcReal+0.5)) Nc++;
165 ElToRefine.
Push(elside);
170 int curporder = POrder.
Pop();
171 if(!curelside.
Exists())
continue;
173 if(cindex < 0)
continue;
180 if(!cintel)
continue;
182 if(curporder == minporder) {
187 cintel->
Divide(cindex,csubindex,1);
191 if(!gelside.
Exists())
continue;
196 for(is=0; is<ns; is++) {
200 ElToRefine.
Push(csub);
201 POrder.
Push(curporder);
292 arq <<
"CurrentEtaAdmissible " << CurrentEtaAdmissible << endl;
295 bool store_error =
false;
301 for(int64_t ielloc=0;ielloc<nel;ielloc++) {
304 if(iel == -1)
continue;
307 PZError <<
"TPZAnalysisError::HPAdapt boundary element with error?\n";
313 int64_t ising, nsing = SingLocal.
NElements();
314 for(ising=0; ising<nsing; ising++) {
315 if(elem == SingLocal[ising].Element()) {
321 if(ising < nsing)
continue;
327 REAL pFn = pFo,
res = 10.0, phi, del, dph,
tol = 0.001;
328 int64_t MaxIter = 100; int64_t iter=0;
329 while (iter < MaxIter && res > tol) {
330 phi = pFo+
log(csi)-pFo*
log(pFn/pFo);
341 PZError <<
"\n - Newton's Method Failed at Element = " << elem->
Reference()->
Id() << endl;
342 if(pFn < 1.) pFn = 1.;
343 REAL factor =
pow(csi,-1.0/pFn)*(
pow(pFn/pFo,pFo/pFn));
350 pFn = pFo; iter = 0; res = 10.0;
351 while (iter < MaxIter && res > tol) {
352 phi = -pFn*
log(factor)-
log(csi)+pFo*
log(pFn/pFo);
353 dph = pFn/(pFo-pFn*
log(factor));
363 PZError <<
"\n - Newton's Method Failed at Element = " << elem->
Reference()->
Id() << endl;
364 if(pFn < 1.) pFn = 1.;
366 while(REAL(pNew) < (pFn+0.5)) pNew++;
375 int64_t index = locel->
Index();
376 elem->
Divide(index,indexsubs,1);
384 REAL
h = 0.,cicjdist;
387 for(
int conni=0;conni<nconn;conni++) {
388 for(
int connj=conni;connj<nconn;connj++) {
390 for(
int coordi=0;coordi<3;coordi++) {
393 cicjdist +=
pow( coor1 - coor2, (REAL)2.0);
395 cicjdist =
sqrt(cicjdist);
396 if(h < cicjdist) h = cicjdist;
407 val[0] = 0.*point[0];
416 int64_t nnodes = gmesh->
NNodes();
422 for(in=0;in<nnodes;in++) {
425 if(nodei) xi = nodei->
Coord(0);
428 for(int64_t jn=in;jn<nnodes;jn++) {
431 if(nodej) xj = nodej->
Coord(0);
else continue;
439 nodes[in] = nodes[keepindex];
440 nodes[keepindex] = commut;
443 ofstream mesh(
"Malha.dat");
444 ofstream graph(
"Graphic.nb");
445 mesh <<
"\nDistribuicao de nos\n\n";
447 for(i=0;i<nnodes;i++) {
449 if(nodei) mesh << nodei->
Coord(0) << endl;
456 for(in=0;in<nnodes;in++) {
459 for(int64_t iel=0;iel<nel;iel++) {
464 if(in==nnodes-1) ic = 1;
467 locnodid[count++] = ic;
474 for(iel=0;iel<nnodes;iel++) {
476 connects[iel] = gelptr[iel]->Reference()->ConnectIndex(locnodid[iel]);
479 for(i=0; i<nnodes; i++) {
482 cout <<
"\nError in structure of dates\n";
483 mesh <<
"\nError in structure of dates\n";
490 mesh <<
"\nSolucao nodal\n\n";
491 for(i=0;i<nnodes;i++) {
492 mesh << sol[i] << endl;
495 int64_t numsols = 5*(nnodes-1)+1;
499 int64_t exp_iel = -1;
500 for(iel=0;iel<nnodes-1;iel++) {
503 expand_sol[exp_iel] = sol[iel];
505 expand_nodes[exp_iel] = nodes[iel].Coord(0);
507 for(
int i=1;i<5;i++) {
509 expand_nodes[exp_iel] = i*h/5. + nodes[iel].Coord(0);
511 gelptr[iel]->Reference()->Solution(qsi,0,locsol);
512 expand_sol[exp_iel] = locsol[0];
515 expand_nodes[numsols-1] = nodes[nnodes-1].Coord(0);
516 expand_sol[numsols-1] = sol[nnodes-1];
518 graph <<
"list = {" << endl;
519 for(int64_t isol=0;isol<numsols;isol++) {
520 if(isol > 0) graph <<
",";
521 STATE expandsol = expand_sol[isol];
522 if(
fabs(expandsol) < 1.e-10) expandsol = 0.;
523 graph <<
"{" << expand_nodes[isol] <<
"," << expandsol <<
"}";
524 if( !((isol+1)%5) ) graph << endl;
527 graph <<
"ListPlot[list, PlotJoined->True, PlotRange->All];" << endl;
546 for(el=0;el<
numel;el++) {
551 errorSum.
Resize(nerrors, 0.);
552 for(
int ii = 0; ii < nerrors; ii++)
553 errorSum[ii] += elerror[ii]*elerror[ii];
577 for(iel=0; iel<nelem; iel++) {
581 if(!gelside.
Exists())
continue;
583 cout <<
"This part needs to be fixed\n";
587 gelsideloc = gelstack.
Pop();
591 if(! celsideloc.
Exists())
continue;
594 for(smel=0; smel<nelsing; smel++)
if(singel[smel].Element() == celsideloc.
Element())
break;
595 if(smel != nelsing) singel.
Push(celsideloc);
TPZFMatrix< STATE > & ElementSolution()
Access method for the element solution vectors.
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
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
void AdjustBoundaryElements()
Will refine the elements associated with a boundary condition till there are no elements constrained ...
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.
Implements computational element and a side. Computational Element.
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
TPZManVector< REAL > fElErrors
Vector with error values by elements.
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Contains declaration of TPZGeoElSide class which represents an element and its side, and TPZGeoElSideIndex class which represents an TPZGeoElSide index.
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.
void OptimizeBandwidth()
Sets the computer connection block number from the graphical connections block number otimization...
int MaterialId() const
Returns the material index of the element.
virtual void EvaluateError(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)> func, TPZVec< REAL > &errors, bool store_error)
Performs an error estimate on the elemen.
Contains declaration of TPZGeoNode class which defines a geometrical node.
REAL Coord(int i) const
Returns i-th coordinate of the current node.
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
TPZStack< TPZCompElSide > fSingular
TPZGeoElSide Reference() const
Reference to the geometric element.
Templated vector implementation.
Defines step solvers class. Solver.
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
TPZCompMesh * fCompMesh
Computational mesh.
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
TPZCompMesh * Mesh() const
Returns the pointer to the computational mesh.
void NullFunction(const TPZVec< REAL > &point, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)
Function to zeroes data.
int64_t NElements() const
Number of elements of the mesh.
void GetSubElements2(TPZStack< TPZGeoElSide > &subelements)
build the list of element/side pairs which compose the current set of points
Declarates the TPZBlock<REAL>class which implements block matrices.
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
clarg::argBool h("-h", "help message", false)
virtual void DefineGraphMesh(int dimension, const TPZVec< std::string > &scalnames, const TPZVec< std::string > &vecnames, const std::string &plotfile)
Define GrapMesh as V3D, DX, MV or VTK depending on extension of the file.
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.
void MathematicaPlot()
Plot to the aproximated solution of the FEM with Mathematica package.
virtual int NSides() const =0
Returns the number of connectivities of the element.
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.
void EqualLevelCompElementList(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected computational elements which have equal level to the current element...
TPZMatrixSolver< STATE > & Solver()
Get the solver matrix.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
void EvaluateError(REAL CurrentEtaAdmissible, bool store_error, std::ostream &out)
Compute the list of errors of all elements and also the admissible error for any element in the grid...
Contains TPZAnalysisError class which implements analysis procedures with hp adaptivity.
Implements SkyLine Structural Matrices. Structural Matrix.
virtual TPZMaterial * Material() const
Identify the material object associated with the element.
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.
void GetSingularElements(TPZStack< TPZCompElSide > &listel)
Search the element whith contain this point.
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.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
TPZAnalysisError(TPZCompMesh *mesh, std::ostream &out)
Object constructors.
void SetAdaptivityParameters(REAL EtaAdmissible, int64_t NIterations)
Set the parameters which will govern the adaptive process.
void Divide(int64_t index, TPZVec< int64_t > &sub, int interpolatesolution=0) override
Implement the refinement of an interpolated element.
int64_t NNodes() const
Number of nodes of the mesh.
Contains declaration of TPZConnect class which represents a set of shape functions associated with a ...
Contains the TPZSkylineStructMatrix class which implements SkyLine Structural Matrices.
TPZManVector< int64_t > fElIndexes
Indexes of the elements vector.
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
void ExpandConnected(TPZStack< TPZCompElSide > &singel)
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
int Exists() const
Verifies if the object is non null (initialized)
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
int64_t Index() const
Returns element index of the mesh fELementVec list.
Contains declaration of TPZCompMesh class which is a repository for computational elements...
virtual void PostProcess(int resolution)
Draw solution over mesh for all dimensions.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
virtual void Run(std::ostream &out=std::cout)
Calls the appropriate sequence of methods to build a solution or a time stepping sequence.
Contains TPZMatrix<TVar>class, root matrix class.
REAL h_Parameter(TPZCompEl *cel)
Calculate the h parameter of the element.
virtual int EffectiveSideOrder(int side) const =0
Returns the actual interpolation order of the polynomial along the side.
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
std::ofstream arq("Param.dat")
Output file with number of iteration made.
T Pop()
Retrieve an object from the stack.
TPZCompEl * Element() const
Gives a pointer to the reference computational element.
int64_t Id() const
Returns the Id of the element.
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
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Implements a geometric node in the pz environment. Geometry.
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.
Free store vector implementation in chunks.
Implements block matrices. Matrix utility.
This class implements a geometric mesh for the pz environment. Geometry.
void ZoomInSingularity(REAL csi, TPZCompElSide elside, REAL singularity_order=0.9)
Calculate pn and hn parameters for the elements neighbours to the element with contain the singular p...
Implements computational mesh. Computational Mesh.
void HPAdapt(REAL CurrentEtaAdmissible, std::ostream &out)
Run one iteration of HP adaptivity.
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
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 EvaluateError(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)> fp, bool store_error, TPZVec< REAL > &errorSum)
Evaluates the error given the two vectors of the analised parameters.
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.
void hp_Adaptive_Mesh_Design(std::ostream &out, REAL &EtaAdmissible)
Run the algorithm of the fast hp adaptive finite element mesh design.
Contains TPZStepSolver class which defines step solvers class.
int Id() const
Returns the identity of the current node.
int64_t fNIterations
Number of iterations.
int64_t NElements() const
Returns the number of elements of the vector.
void SetDirect(const DecomposeType decomp)
Defines the interface of a computational element. Computational Element.
TPZFMatrix< STATE > & Solution()
Access the solution vector.
Implements computational element based on an interpolation space. Computational Element.
#define PZError
Defines the output device to error messages and the DebugStop() function.
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
void PlotLocal(int64_t iter, REAL CurrentEtaAdmissible, std::ostream &out)
Postprocess the intermediate solutions.