NeoPZ
main.cpp
Go to the documentation of this file.
1 #ifdef HAVE_CONFIG_H
2 #include <pz_config.h>
3 #endif
4 
5 #include "pzvec.h"
6 #include "pzstack.h"
7 #include "pzfmatrix.h"
8 #include "pzfstrmatrix.h"
9 #include "pzlog.h"
10 
11 #include "pzgmesh.h"
12 #include "pzcmesh.h"
13 #include "pzcompel.h"
14 #include "TPZInterfaceEl.h"
15 #include "pzgeoelside.h"
16 #include "TPZGeoLinear.h"
17 #include "pzgeopoint.h"
18 
19 #include "TPZRefPattern.h"
20 #include "tpzgeoelrefpattern.h"
21 #include "tpzcompmeshreferred.h"
22 #include "tpzautopointer.h"
23 #include "pzbndcond.h"
24 #include "pzanalysis.h"
25 
27 #include "pzstepsolver.h"
28 #include "pzstrmatrix.h"
29 #include "pzfstrmatrix.h"
30 #include "TPZFrontNonSym.h"
31 #include "TPZFrontSym.h"
32 #include "TPBSpStructMatrix.h"
33 #include "TPZSpStructMatrix.h"
34 #include "pzbstrmatrix.h"
35 
36 #include "pzpoisson3d.h"
37 //#include "pzhybridpoisson.h"
38 #include "pzpoisson3dreferred.h"
39 #include "mixedpoisson.h"
40 #include "pzelasmat.h"
41 #include "pzelasthybrid.h"
42 #include "pzmat1dlin.h"
43 #include "TPZVecL2.h"
44 #include "TPZMatLaplacian.h"
45 
47 #include "pzelementgroup.h"
48 #include "TPZCompMeshTools.h"
49 #include "pzcondensedcompel.h"
50 #include "pzfunction.h"
51 #include "pzgraphmesh.h"
52 #include "pzfmatrix.h"
53 
54 #include "pzlog.h"
55 
56 #include "TPZVTKGeoMesh.h"
57 #include "pzgengrid.h"
58 #include "TPZExtendGridDimension.h"
59 #include "pzcheckgeom.h"
60 
61 #include "TPZMHMeshControl.h"
62 
63 #include <iostream>
64 #include <string>
65 
66 #include <math.h>
67 #include <set>
68 
69 
70 
71 using namespace std;
72 
73 
76 
77 
79 
81 
82 #ifdef LOG4CXX
83 static LoggerPtr logger(Logger::getLogger("pz.mainskeleton"));
84 #endif
85 
87 
88 TPZAutoPointer<TPZCompMesh> CreateCompMesh(int dimension, int porder, int64_t nelem, MRegular regular);
89 
90 int main(int argc, char *argv[])
91 {
92 #ifdef LOG4CXX
94 #endif
95 
96  int porder = 1;
97  int dimension = 2;
98  int nelem = 1000000;
99  TPZAutoPointer<TPZCompMesh> cmesh = CreateCompMesh(dimension, porder, nelem, EUniform);
100 
101 
102  std::cout << "Computational mesh created\n";
103  std::cout.flush();
104 //#ifdef PZDEBUG
105 // {
106 // std::ofstream out("../Pressure.txt");
107 // cmesh->Print(out);
108 // }
109 //#endif
110 
111  std::cout << "Number of equations " << cmesh->NEquations() << std::endl;
112  std::cout << "Number of elements " << cmesh->NElements() << std::endl;
113 
114  //calculo solution
115  TPZAnalysis *an = new TPZAnalysis(cmesh,false);
116 
117  TPZSkylineStructMatrix strmat(cmesh);
118 
119 //#ifndef PZDEBUG
120 // skyl.SetNumThreads(1);
121 //#endif
122  an->SetStructuralMatrix(strmat);
124  step.SetDirect(ELDLt);
125  an->SetSolver(step);
126  std::cout << "Assembly\n";
127  an->AssembleResidual();
128  std::cout << "Once\n";
129  an->AssembleResidual();
130  std::cout << "Finished\n";
131  return 0;
132 }
133 
134 
135 
137 {
138 
139  int ir, iel, k;
140  int nel=0, dim=0;
141  int ndims = dims.size();
142  for(ir = 0; ir < nref; ir++ )
143  {
144  TPZVec<TPZGeoEl *> filhos;
145  nel = gmesh->NElements();
146 
147  for (iel = 0; iel < nel; iel++ )
148  {
149  TPZGeoEl * gel = gmesh->ElementVec()[iel];
150  if(!gel) DebugStop();
151 
152  dim = gel->Dimension();
153 
154  for(k = 0; k<ndims; k++)
155  {
156  if(dim == dims[k])
157  {
158  gel->Divide (filhos);
159  break;
160  }
161  }
162  }
163  }
164 
165 }
166 
167 
168 
171 {
172  TPZManVector<REAL,3> x0(3,0.),x1(3,0.);
173  REAL scale = pow(2, nref);
174  REAL lx = nblocks[0]*scale;
175  REAL ly = nblocks[1]*scale;
176  REAL lz = scale;
177  x1[0] = lx;
178  x1[1] = ly;
179  x1[2] = 0.;
180  TPZManVector<int,3> nx(nblocks);
181  TPZGenGrid gengrid(nx,x0,x1);
182  TPZAutoPointer<TPZGeoMesh> meshresult2d = new TPZGeoMesh;
183  gengrid.SetRefpatternElements(false);
184  gengrid.Read(meshresult2d);
185 
186  gengrid.SetBC(meshresult2d.operator->(), 4, -1);
187  gengrid.SetBC(meshresult2d.operator->(), 5, -1);
188  gengrid.SetBC(meshresult2d.operator->(), 6, -1);
189  gengrid.SetBC(meshresult2d.operator->(), 7, -1);
190  if (dim ==2) {
191  return meshresult2d;
192  }
193  if (dim != 3) {
194  DebugStop();
195  }
196  TPZExtendGridDimension extend(meshresult2d,lz);
197  // create uniform refinement elements
198  extend.SetElType(0);
199  TPZGeoMesh *res3d = extend.ExtendedMesh(nblocks[2],-2,-2);
200  TPZAutoPointer<TPZGeoMesh> meshresult3d(res3d);
201 
202  TPZCheckGeom check(res3d);
203  check.UniformRefine(nref);
204 
205 
206 #ifdef PZDEBUG
207  std::ofstream vtkfile("../gmesh.vtk");
208  TPZVTKGeoMesh::PrintGMeshVTK(res3d, vtkfile);
209 #endif
210  return meshresult3d;
211 }
212 
213 
214 
216 {
217  TPZAutoPointer<TPZCompMesh> cmeshPressure = new TPZCompMesh(gmesh);
218  cmeshPressure->SetDimModel(gmesh->Dimension());
219  cmeshPressure->ApproxSpace().SetAllCreateFunctionsContinuous();
220 // cmeshPressure->ApproxSpace().CreateDisconnectedElements(true);
221  cmeshPressure->SetDefaultOrder(porder);
222  TPZMatLaplacian *matl2 = new TPZMatLaplacian(1);
223  matl2->SetDimension(cmeshPressure->Dimension());
224  matl2->SetSymmetric();
225  cmeshPressure->InsertMaterialObject(matl2);
226  cmeshPressure->AutoBuild();
227  std::cout << "Computational mesh created\n";
228  return cmeshPressure;
229 }
230 
231 TPZAutoPointer<TPZCompMesh> CreateCompMesh(int dimension, int porder, int64_t nelem, MRegular regular)
232 {
234  int pincr = 4;
235  if (dimension == 3) {
236  int blocksize = ((int)pow(nelem, 0.33))+1;
238  int nref = 0;
239  TPZManVector<int> nblocks(3,blocksize);
240  gmesh = MalhaGeom(dimension, nblocks, nref);
241  gmesh->SetDimension(3);
242  std::cout << "Geometric mesh created elements " << gmesh->NElements() << std::endl;
243  result = CreatePressureMesh(gmesh, porder);
244  }
245  else if (dimension == 2)
246  {
247  pincr = 6;
248  int blocksize = ((int)sqrt(nelem))+1;
250  int nref = 0;
251  TPZManVector<int> nblocks(2,blocksize);
252  gmesh = MalhaGeom(dimension, nblocks, nref);
253  gmesh->SetDimension(2);
254  std::cout << "Geometric mesh created elements " << gmesh->NElements() << std::endl;
255  result = CreatePressureMesh(gmesh, porder);
256  }
257  else
258  {
259  DebugStop();
260  }
261  if (regular == EUnbalanced) {
262  for (int64_t el =0; el < result->NElements(); el += result->NElements()/10) {
263  TPZCompEl *cel = result->Element(el);
264  TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement *>(cel);
265  if (!intel) {
266  DebugStop();
267  }
268  intel->PRefine(porder+pincr);
269  }
270  }
271  result->ExpandSolution();
272  return result;
273 }
274 
275 
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
Contains the TPZFrontSym class which implements decomposition process of the frontal matrix (case sym...
This class performs a series of consistency tests on geometric transformations between elements...
Definition: pzcheckgeom.h:16
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
Definition: pzmatrix.h:52
Contains the TPZParSkylineStructMatrix class which defines parallel structural matrix for skyline mat...
Contains declaration of TPZGeoElSide class which represents an element and its side, and TPZGeoElSideIndex class which represents an TPZGeoElSide index.
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.
Definition: pzanalysis.cpp:82
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
Contains declaration of TPZCompEl class which defines the interface of a computational element...
Templated vector implementation.
Contains the declaration of the TPZElementGroup class, which implements an computational element whic...
Contains declaration of TPZCheckGeom class which performs a series of consistency tests on geometric ...
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
Implements the generation of a multilayered bi-dimensional geometric grid. Getting Data...
Definition: pzgengrid.h:29
Contains the TPZFrontNonSym class which implements storage and decomposition process of the frontal m...
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
Contains the TPZStructMatrixOR class which responsible for a interface among Matrix and Finite Elemen...
virtual void Divide(TPZVec< TPZGeoEl *> &pv)
Divides the element and puts the resulting elements in the vector.
Definition: pzgeoel.h:742
void SetDimension(int dim)
Set Dimension.
Definition: pzgmesh.h:285
Contains the TPZMatPoisson3d class.
void UniformRefine(int nDiv)
Uniform refine the geometric mesh.
TPZAutoPointer< TPZGeoMesh > MalhaGeom(int dimension, TPZVec< int > &nblocks, int nref)
malha geometrica de grande porte
Definition: main.cpp:170
Contains the TPZFStructMatrix class which implements Full Structural Matrices.
void SetDefaultOrder(int order)
Definition: pzcmesh.h:403
Implements SkyLine Structural Matrices. Structural Matrix.
TPZGeoMesh * ExtendedMesh()
It reads the mesh since the archive of entrance finemesh, or since the fFineGeoMesh passed in the con...
clarg::argInt porder("-p", "porder", 2)
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
Contains the TPZSpStructMatrix class which implements sparse structural matrices. ...
TPZCompEl * Element(int64_t iel)
Definition: pzcmesh.h:185
TPZCreateApproximationSpace & ApproxSpace()
Definition: pzcmesh.h:498
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
Implements the sequence of actions to perform a finite element analysis. Analysis.
Definition: pzanalysis.h:32
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
Contains declaration of TPZCompMeshReferred class which implements the structure to allow one mesh to...
virtual void SetBC(TPZGeoMesh *gr, int side, int bc)
Generate boundary geometric elements associated with the side of the rectangular domain.
Definition: pzgengrid.cpp:706
Contains the TPZBandStructMatrix class which implements Banded Structural Matrices.
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
Contains declaration of TPZInterfaceElement class which computes the contribution over an interface b...
virtual void ExpandSolution()
Adapt the solution vector to new block dimensions.
Definition: pzcmesh.cpp:396
Contains the TPZElasticityMaterial class which implements a two dimensional elastic material in plane...
int Dimension() const
Returns the dimension of the simulation.
Definition: pzcmesh.h:148
Contains the declaration of the TPZBuildmultiphysicsMesh class.
Generates a three dimensional mesh as an extension of a two dimensional mesh. Getting Data...
virtual void AutoBuild(const std::set< int > *MaterialIDs)
Creates the computational elements, and the degree of freedom nodes.
Definition: pzcmesh.cpp:308
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
Contains the TPZGenGrid class which implements the generation of a multilayered geometric grid (two-d...
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
void SetAllCreateFunctionsContinuous()
Create continuous approximation spaces.
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
Contains the TPZGraphMesh class which represents a graphical mesh used for post processing purposes...
Contains the TPZExtendGridDimension class which generates a three dimensional mesh as an extension of...
Contains the TPZMatPoisson3dReferred class which implements a version of TPZMatPoisson3d (convection...
void SetSymmetric()
Set material elliptic term as the global element method, i.e. the symmetrical formulation.
static void PrintGMeshVTK(TPZGeoMesh *gmesh, std::ofstream &file, bool matColor=true)
Default constructor for graphical mesh with VTK format.
Contains declaration of TPZCompMesh class which is a repository for computational elements...
Contains the TPZRefPattern class which defines the topology of the current refinement pattern to a me...
void SetDimension(int dim)
void SetDimModel(int dim)
Set de dimension of the domain of the problem.
Definition: pzcmesh.h:139
A simple stack.
Contains the TPZGeoPoint class which implements the geometry of a point element or 0-D element...
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
Definition: pzreal.h:487
Contains the TPBSpStructMatrix class which assembles on the pair equations.
int InsertMaterialObject(TPZMaterial *mat)
Insert a material object in the datastructure.
Definition: pzcmesh.cpp:287
void InitializePZLOG()
Initializes log file for log4cxx with commom name log4cxx.cfg.
Definition: pzlog.cpp:14
virtual int Dimension() const =0
Returns the dimension of the element.
Contains the TPZMat1dLin class which implements a one-dimensional linear problem. ...
int Dimension()
Get Dimension.
Definition: pzgmesh.h:291
virtual void AssembleResidual()
Assemble the load vector.
Definition: pzanalysis.cpp:288
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
TPZAutoPointer< TPZCompMesh > CreateCompMesh(int dimension, int porder, int64_t nelem, MRegular regular)
Definition: main.cpp:231
TPZAutoPointer< TPZCompMesh > CreatePressureMesh(TPZAutoPointer< TPZGeoMesh > gmesh, int porder)
Definition: main.cpp:215
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
void PRefine(int order) override
Changes the interpolation order of a side. Updates all constraints and block sizes ...
Definition: pzintel.cpp:1592
void RefinamentoUniforme(TPZAutoPointer< TPZGeoMesh > gmesh, int nref, TPZVec< int > dims)
Definition: main.cpp:136
Contains TPZStepSolver class which defines step solvers class.
MRegular
Definition: main.cpp:86
Contains the TPZMatLaplacian class.
void SetDirect(const DecomposeType decomp)
Contains the TPZElasticityHybridMaterial class which implements a two dimensional elastic material to...
void SetRefpatternElements(bool refpat)
Generate element of type refpattern or uniform refinement.
Definition: pzgengrid.h:202
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
Contains the TPZVTKGeoMesh class which implements the graphical mesh to VTK environment to geometric ...
Contains the declaration of the TPZCondensedCompEl class, which implements an computational element w...
virtual short Read(TPZGeoMesh *mesh, int matid=1)
Add nodes and elements to the object mesh.
Definition: pzgengrid.cpp:64
int main()
Definition: main.cpp:60
Implements computational element based on an interpolation space. Computational Element.
Definition: pzintel.h:27
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138