41 if (POrderBeginAndEnd.
size()!=2)
43 std::cout <<
" POrderBeginAndEnd Vector must have size == 2 and contain just two values, the first and last approximation orders. " << std::endl;
44 std::cout <<
" Some like POrderBeginAndEnd[0] = 1, POrderBeginAndEnd[1] = 3 " << std::endl;
48 if (ndivinterval.
size()!=2)
50 std::cout <<
" ndivinterval Vector must have size == 2 and contain just two values, the first and last number of uniform refinements. " << std::endl;
51 std::cout <<
" Some like ndivinterval[0] = 0, ndivinterval[1] = 3 for simulations with 0, 1, 2 and 3 refinements " << std::endl;
52 std::cout <<
" Some like ndivinterval[0] = 1, ndivinterval[1] = 1 for simulations with 1 refinement " << std::endl;
56 int sizeErrorMatrix = (ndivinterval[1]-ndivinterval[0])*(POrderBeginAndEnd[1] - POrderBeginAndEnd[0]) + 1;
57 int errorposition = 0;
59 errors.
Resize(sizeErrorMatrix, 4);
61 for(
int p = POrderBeginAndEnd[0]; p <= POrderBeginAndEnd[1]; p++)
64 for (
int ndiv = ndivinterval[0]; ndiv<=ndivinterval[1]; ndiv++)
68 std::cout<<
" BEGIN (Quadrilateral Domain) - Polinomial degree: " << ordemP <<
" rerfinement size (h): " << ndiv << std::endl;
95 for (int64_t iel=0; iel<cmeshH1->
NElements(); iel++) {
108 ErrorH1(cmeshH1, ordemP, ndiv, errorposition, errors);
143 std::cout <<
"Computing Errors\n";
175 std::cout <<
"Computing Errors\n";
185 std::cout<<
" END (QUAD) - polinomial degree: " << ordemP <<
" refinement size (h): " << ndiv << std::endl;
192 std::cout<<
" The End " << std::endl;
199 if (POrderBeginAndEnd.
size()!=2)
201 std::cout <<
" POrderBeginAndEnd Vector must have size == 2 and contain just two values, the first and last approximation orders. " << std::endl;
202 std::cout <<
" Some like POrderBeginAndEnd[0] = 1, POrderBeginAndEnd[1] = 3 " << std::endl;
206 if (ndivinterval.
size()!=2)
208 std::cout <<
" ndivinterval Vector must have size == 2 and contain just two values, the first and last number of uniform refinements. " << std::endl;
209 std::cout <<
" Some like ndivinterval[0] = 0, ndivinterval[1] = 3 for simulations with 0, 1, 2 and 3 refinements " << std::endl;
210 std::cout <<
" Some like ndivinterval[0] = 1, ndivinterval[1] = 1 for simulations with 1 refinement " << std::endl;
214 for(
int p = POrderBeginAndEnd[0]; p <= POrderBeginAndEnd[1]; p++)
216 output <<
"\n WHEN p = " << p <<
" \n " << endl;
217 output <<
"ndiv " << setw(6) <<
"DoFTot" << setw(20) <<
"DofCond" << setw(28) <<
"PrimalL2Error" << setw(35) <<
"L2DualError" << endl;
219 for (
int ndiv = ndivinterval[0]; ndiv<=ndivinterval[1]; ndiv++)
223 std::cout<<
" BEGIN (Quadrilateral Domain) - Polinomial degree: " << ordemP <<
" rerfinement size (h): " << ndiv << std::endl;
253 for (int64_t iel=0; iel<cmeshH1->
NElements(); iel++) {
268 ErrorH1(cmeshH1, ordemP, ndiv, output, dofTotal, dofCondensed);
307 std::cout <<
"Computing Errors\n";
346 std::cout <<
"Computing Errors\n";
359 output <<
"\n ----------------------------------------------------------------------------- " << endl;
360 std::cout<<
" END (Quadrilateral Domain) - Polinomial degree: " << p << std::endl;
364 std::cout<<
" The End " << std::endl;
374 std::cout <<
"Wrong dimension" << std::endl;
400 gmesh->
NodeVec()[in].SetCoord(coord);
401 gmesh->
NodeVec()[in].SetNodeId(in);
406 gmesh->
NodeVec()[in].SetCoord(coord);
407 gmesh->
NodeVec()[in].SetNodeId(in);
412 gmesh->
NodeVec()[in].SetCoord(coord);
413 gmesh->
NodeVec()[in].SetNodeId(in);
418 gmesh->
NodeVec()[in].SetCoord(coord);
419 gmesh->
NodeVec()[in].SetNodeId(in);
475 for (
int iref = 0; iref < ndiv; iref++) {
477 for (
int iel = 0; iel < nel; iel++) {
502 for (
int id = 0;
id < dim;
id++){
512 solp[0] =
sin(M_PI*x)*
sin(M_PI*y);
513 flux(0,0) = -M_PI*
cos(M_PI*x)*
sin(M_PI*y);
514 flux(1,0) = -M_PI*
cos(M_PI*y)*
sin(M_PI*x);
528 for (
int id = 0;
id < dim;
id++){
536 ff[0] = 2.*M_PI*M_PI*
sin(M_PI*x)*
sin(M_PI*y);
556 for (
int id = 0;
id < dim;
id++){
566 solp[0] =
sin(M_PI*x)*
sin(M_PI*y);
567 flux(0,0) = -M_PI*
cos(M_PI*x)*
sin(M_PI*y);
568 flux(1,0) = -M_PI*
cos(M_PI*y)*
sin(M_PI*x);
586 for (
int id = 0;
id < dim;
id++){
596 ff[0] = -2.*M_PI*M_PI*
sin(M_PI*x)*
sin(M_PI*y);
759 bool h1function =
true;
774 for(
int i=0; i<ncon; i++)
785 for(
int i=0; i<nel; i++){
805 for(
int i =0; i<ncel; i++){
807 if(!compEl)
continue;
840 for (
int id = 0;
id < 3;
id++){
846 InvPermTensor = InvTP;
882 BCond1->SetForcingFunction(FBCond1);
888 BCond2->SetForcingFunction(FBCond2);
894 BCond3->SetForcingFunction(FBCond3);
900 BCond4->SetForcingFunction(FBCond4);
924 std::map<int64_t, int64_t> bctoel, eltowrap;
925 for (int64_t el=0; el<nel; el++) {
932 while (neighbour != gelside) {
933 if (neighbour.Element()->Dimension() == dim && neighbour.Element()->Reference()) {
938 neighbour = neighbour.Neighbour();
940 if (neighbour == gelside) {
947 for(int64_t el = 0; el < nel; el++)
953 for (int64_t el =0; el < wrapEl.
size(); el++) {
955 int64_t index = cel->
Index();
956 eltowrap[index] = el;
959 meshvec[0]->CleanUpUnconnectedNodes();
963 std::map<int64_t, int64_t>::iterator it;
964 for (it = bctoel.begin(); it != bctoel.end(); it++) {
965 int64_t bcindex = it->first;
966 int64_t elindex = it->second;
967 if (eltowrap.find(elindex) == eltowrap.end()) {
970 int64_t wrapindex = eltowrap[elindex];
976 wrapEl[wrapindex].
Push(bcmf);
981 int64_t index, nenvel;
984 for(int64_t ienv=0; ienv<nenvel; ienv++){
988 for(
int jel=0; jel<nel; jel++){
996 for (int64_t ienv=0; ienv<nenvel; ienv++) {
999 for (
int ic=0; ic<nc; ic++) {
1023 for (int64_t el=0; el<nel; el++) {
1036 int nerr = elerror.
size();
1037 globalerrors.
resize(nerr);
1039 for (
int i=0; i<nerr; i++) {
1040 globalerrors[i] += elerror[i]*elerror[i];
1045 errors.
PutVal(pos, 0, p);
1046 errors.
PutVal(pos, 1, ndiv);
1047 errors.
PutVal(pos, 2,
sqrt(globalerrors[1]));
1048 errors.
PutVal(pos, 3,
sqrt(globalerrors[2]));
1058 for (int64_t el=0; el<nel; el++) {
1071 int nerr = elerror.
size();
1072 globalerrors.
resize(nerr);
1074 for (
int i=0; i<nerr; i++) {
1075 globalerrors[i] += elerror[i]*elerror[i];
1079 out << ndiv << setw(10) << DoFT << setw(20) << DofCond << setw(28) <<
sqrt(globalerrors[1]) << setw(35) <<
sqrt(globalerrors[2]) << endl;
1089 for (int64_t el=0; el<nel; el++) {
1095 int nerr = elerror.
size();
1096 for (
int i=0; i<nerr; i++) {
1097 globalerrorsDual[i] += elerror[i]*elerror[i];
1107 for (int64_t el=0; el<nel; el++) {
1111 int nerr = elerror.
size();
1112 globalerrorsPrimal.
resize(nerr);
1114 for (
int i=0; i<nerr; i++) {
1115 globalerrorsPrimal[i] += elerror[i]*elerror[i];
1122 errors.
PutVal(pos, 0, p);
1123 errors.
PutVal(pos, 1, ndiv);
1124 errors.
PutVal(pos, 2,
sqrt(globalerrorsPrimal[1]));
1125 errors.
PutVal(pos, 3,
sqrt(globalerrorsDual[1]));
1134 for (int64_t el=0; el<nel; el++) {
1140 int nerr = elerror.
size();
1141 for (
int i=0; i<nerr; i++) {
1142 globalerrorsDual[i] += elerror[i]*elerror[i];
1152 for (int64_t el=0; el<nel; el++) {
1156 int nerr = elerror.
size();
1157 globalerrorsPrimal.
resize(nerr);
1159 for (
int i=0; i<nerr; i++) {
1160 globalerrorsPrimal[i] += elerror[i]*elerror[i];
1165 out << ndiv << setw(10) << DoFT << setw(20) << DofCond << setw(28) <<
sqrt(globalerrorsPrimal[1]) << setw(35) <<
sqrt(globalerrorsDual[1]) << endl;
1171 int nEl= mesh-> NElements();
1175 for (
int iel=0; iel<nEl; iel++) {
1183 for (
int icon=0; icon<ncon-1; icon++){
1185 corder = co.
Order();
1187 if(corder!=cordermin){
1188 cordermin = corder-1;
1204 std::cout <<
"Numero de equacoes "<< fCmesh->
NEquations()<< std::endl;
1206 bool isdirect =
true;
1207 bool simetrico =
true;
1208 bool isfrontal =
false;
1262 Solver->
SetGMRES(20, 20, *precond, 1.e-18, 0);
void SolveSyst(TPZAnalysis &an, TPZCompMesh *fCmesh)
int64_t NElements() const
Number of computational elements allocated.
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
static void ForcingBC3D(const TPZVec< REAL > &pt, TPZVec< STATE > &disp)
Material which implements a Lagrange Multiplier.
void SetPermeabilityTensor(TPZFMatrix< REAL > K, TPZFMatrix< REAL > invK)
TPZCompMesh * CMeshFlux(TPZGeoMesh *gmesh, int pOrder, int dim)
void AdjustBoundaryElements()
Will refine the elements associated with a boundary condition till there are no elements constrained ...
void SetAllCreateFunctionsContinuous()
void IncrementElConnected()
Increment fNElConnected.
int Set(const int index, const int dim, const int pos=-1)
Modifies existing block dimensions or creates a new block with given index.
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
void SetStructuralMatrix(TPZAutoPointer< TPZStructMatrix > strmatrix)
Set structural matrix as auto pointer for analysis.
Implements Banded Structural Matrices. Structural Matrix.
int MaterialId() const
Returns the material index of the element.
void ChangeExternalOrderConnects(TPZCompMesh *mesh)
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.
virtual int NConnects() const override
Returns the number of nodes of the element.
virtual void resize(const int64_t newsize)
static void AddElements(TPZVec< TPZCompMesh *> &cmeshVec, TPZCompMesh *MFMesh)
Creating multiphysic elements into mphysics computational mesh. Method to add elements in the mesh mu...
void SetOrder(int order, int64_t index)
Set the order of the shapefunction associated with the connect.
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
static void ForcingH1(const TPZVec< REAL > &pt, TPZVec< STATE > &ff, TPZFMatrix< STATE > &flux)
void ErrorH1(TPZCompMesh *l2mesh, int p, int ndiv, int pos, TPZFMatrix< REAL > &errors)
Defines step solvers class. Solver.
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
virtual int Dimension() const =0
Dimension of the element.
static void TransferFromMultiPhysics(TPZVec< TPZCompMesh *> &cmeshVec, TPZCompMesh *MFMesh)
Transfer information from a specific mesh multiphysics for the current specific set of meshes...
void SetLagrangeMultiplier(unsigned char mult)
Set the connect as a pressure connect or not.
int64_t NElements() const
Number of elements of the mesh.
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Class which groups elements to characterize dense matrices.
int64_t NElements() const
Access method to query the number of elements of the vector.
TPZGeoElSide Neighbour() const
virtual int NSides() const =0
Returns the number of connectivities of the element.
virtual void Divide(TPZVec< TPZGeoEl *> &pv)
Divides the element and puts the resulting elements in the vector.
void PrintErrors(ApproximationSpace problem, Eltype element, TPZVec< int > POrderBeginAndEnd, TPZVec< int > ndivinterval, TPZVec< REAL > &errors, std::ostream &output)
void SetDimension(int dim)
Set Dimension.
void LoadReferences()
Map this grid in the geometric grid.
void CreateDisconnectedElements(bool create)
Determine if the mesh will be created with disconnected elements After the mesh is created...
static void AddConnects(TPZVec< TPZCompMesh *> &cmeshVec, TPZCompMesh *MFMesh)
void SetDefaultOrder(int order)
Implements SkyLine Structural Matrices. Structural Matrix.
This abstract class defines the behaviour which each derived class needs to implement.
static void ForcingBC4D(const TPZVec< REAL > &pt, TPZVec< STATE > &disp)
unsigned char LagrangeMultiplier() const
Access method to return the indication whether the connect is associated with a pressure lagrange mul...
static void SolExataH1(const TPZVec< REAL > &pt, TPZVec< STATE > &solp, TPZFMatrix< STATE > &flux)
int64_t size() const
Returns the number of elements of the vector.
void SetForcingFunctionExact(TPZAutoPointer< TPZFunction< STATE > > fp)
Sets a procedure as exact solution for the problem.
TPZCompEl * Element(int64_t iel)
void Resize(const int newsize)
Increase the size of the chunk vector.
unsigned char Order() const
Access function to return the order associated with the connect.
TPZCreateApproximationSpace & ApproxSpace()
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
static void SetTensorialShape(TPZCompMesh *cmesh)
Sets tensorial shape functions for all Discontinuous elements in cmesh.
Implements the sequence of actions to perform a finite element analysis. Analysis.
virtual TPZMatrix< STATE > * Create()
void Push(const T object)
Pushes a copy of the object on the stack.
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
virtual void SetDecomposeType(DecomposeType dectype)
Set the decomposition type.
void SetMaxNodeId(int64_t id)
Used in patch meshes.
Implements a generic geometric element which is refined according to a generic refinement pattern...
static void TransferFromMeshes(TPZVec< TPZCompMesh *> &cmeshVec, TPZCompMesh *MFMesh)
Transfer information from a specific set of meshes for the current mesh multiphysics.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
void SetAllCreateFunctionsDiscontinuous()
#define DebugStop()
Returns a message to user put a breakpoint in.
void Run(ApproximationSpace problem, Eltype element, TPZVec< int > POrderBeginAndEnd, TPZVec< int > ndivinterval, TPZFMatrix< REAL > &errors)
virtual void ExpandSolution()
Adapt the solution vector to new block dimensions.
virtual void SetNumThreads(int n)
void SetAllCreateFunctionsHDiv()
int Dimension() const
Returns the dimension of the simulation.
virtual void ComputeNodElCon()
Compute the number of elements connected to each connect object.
TPZCompMesh * CMeshMixed(TPZGeoMesh *gmesh, TPZVec< TPZCompMesh *> meshvec)
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
virtual void AutoBuild(const std::set< int > *MaterialIDs)
Creates the computational elements, and the degree of freedom nodes.
unsigned int NShape() const
void SetNShape(int nshape)
Set the number of shape functions associated with the connect.
virtual void SetReferenceMatrix(TPZAutoPointer< TPZMatrix< TVar > > matrix)
This method gives a preconditioner to share a matrix with the referring solver object.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
void ErrorPrimalDual(TPZCompMesh *l2mesh, TPZCompMesh *hdivmesh, int p, int ndiv, int pos, TPZFMatrix< REAL > &errors)
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
int64_t NConnects() const
Number of connects allocated including free nodes.
REAL co[8][3]
Coordinates of the eight nodes.
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
Class which implements an element which condenses the internal connects.
int64_t Index() const
Returns element index of the mesh fELementVec list.
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
void SetDimModel(int dim)
Set de dimension of the domain of the problem.
static void SolExata(const TPZVec< REAL > &pt, TPZVec< STATE > &solp, TPZFMatrix< STATE > &flux)
virtual void Run(std::ostream &out=std::cout)
Calls the appropriate sequence of methods to build a solution or a time stepping sequence.
virtual int64_t ConnectIndex(int i) const =0
Returns the index of the ith connectivity of the element.
Computes the contribution over an interface between two discontinuous elements. Computational Element...
virtual int HasSubElement() const =0
Return 1 if the element has subelements.
virtual int NConnects() const =0
Returns the number of nodes of the element.
TPZGeoEl * Element() const
void BuildConnectivity()
Build the connectivity of the grid.
TPZCompMesh * CMeshPressure(TPZGeoMesh *gmesh, int pOrder, int dim)
virtual TPZBndCond * CreateBC(TPZMaterial *reference, int id, int typ, TPZFMatrix< STATE > &val1, TPZFMatrix< STATE > &val2)
Creates an object TPZBndCond derived of TPZMaterial.
int InsertMaterialObject(TPZMaterial *mat)
Insert a material object in the datastructure.
static void SetTotalOrderShape(TPZCompMesh *cmesh)
Set total order shape functions for all Discontinuous elements in cmesh.
virtual void CleanUpUnconnectedNodes()
Delete the nodes which have no elements connected to them.
virtual int Dimension() const =0
Returns the dimension of the element.
int Dimension()
Get Dimension.
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
This class implements a geometric mesh for the pz environment. Geometry.
This class implements a stack object. Utility.
void SetForcingFunction(TPZAutoPointer< TPZFunction< STATE > > fp)
Sets a procedure as source function for the material.
void SetPolynomialOrder(int porder)
Implements computational mesh. Computational Mesh.
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
static void ForcingBC2D(const TPZVec< REAL > &pt, TPZVec< STATE > &disp)
static void Forcing(const TPZVec< REAL > &pt, TPZVec< STATE > &ff)
TPZGeoMesh * GMesh(int dim, bool ftriang, int ndiv)
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.
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
int64_t NElements() const
Returns the number of elements of the vector.
static void ForcingBC1D(const TPZVec< REAL > &pt, TPZVec< STATE > &disp)
void SetCenterPoint(int i, REAL x)
TPZCompMesh * CMeshH1(TPZGeoMesh *gmesh, int pOrder, int dim)
static void AddWrap(TPZMultiphysicsElement *mfcel, int matskeleton, TPZStack< TPZStack< TPZMultiphysicsElement *, 7 > > &ListGroupEl)
Create skeleton elements of the wrap of me.
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
void SetDirect(const DecomposeType decomp)
This class implements a discontinuous element (for use with discontinuous Galerkin). Computational Element.
void ResetReference()
Resets all load references in elements and nodes.
Is a structural matrix with parallel techniques included. Structural Matrix Frontal.
Defines the interface of a computational element. Computational Element.
Material to solve a mixed poisson problem 3D by multiphysics simulation.
void SetAllCreateFunctionsMultiphysicElem()
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
int PutVal(const int64_t row, const int64_t col, const TVar &value) override
Put values without bounds checking This method is faster than "Put" if DEBUG is defined.
virtual void AddElement(TPZCompEl *cel)
add an element to the element group
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
void SetGMRES(const int64_t numiterations, const int numvectors, const TPZMatrixSolver< TVar > &pre, const REAL tol, const int64_t FromCurrent)
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
This class implements a reference counter mechanism to administer a dynamically allocated object...