NeoPZ
main.cpp
Go to the documentation of this file.
1 
7 #include "arglib.h" // clarg:: command line arguments lib
8 #include "run_stats_table.h"
9 #include "CedricTest.h" // TCedricTest
10 #include "TPZRefPatternTools.h" // gRefDBase
11 #include "pzcompel.h" // TPZCompEl
12 
13 /* Command line arguments */
14 clarg::argInt nsub ("-nsub", "number of substructures", 15);
15 clarg::argInt porder ("-p", "porder", 2);
16 clarg::argInt gcase ("-g", "gcase", 1);
17 clarg::argBool help ("-h", "help message", false);
18 
19 void usage (char *prg)
20 {
21  std::cout << "\nUsage: " << prg << std::endl;
22  std::cout << "Arguments: "<< std::endl;
23  clarg::arguments_descriptions (cout, " ", "\n");
24 }
25 
26 #ifdef LOG4CXX
27 #include "pzlog.h"
28 static LoggerPtr logger(Logger::getLogger("pz.Cedric-Perf"));
29 #endif
30 
31 void UniformRefinement(const int nDiv, TPZGeoMesh *gmesh, const int dim, bool allmaterial=false, const int matidtodivided=1);
32 
33 RunStatsTable cedric_rst ("-ced_rdt", "TCedric::Run statistics raw data table.");
34 
35 
36 int main (int argc, char **argv)
37 {
38 
39 
40  /* Log initialization */
41 #ifdef LOG4CXX
43 #endif
44  /* Parse the arguments */
45  if (clarg::parse_arguments(argc, argv)) {
46  cerr << "Error when parsing the arguments!" << endl;
47  return 1;
48  }
49  /* Help message */
50  if (help.get_value()) {
51  usage(argv[0]);
52  return 0;
53  }
54  /* Check if the command line arguments are valid */
55  if(porder.get_value() > 10 || gcase.get_value() > 4 || nsub.get_value() > 100) {
56  std::cout << "\nParameter out of avaliable limit.";
57  return 1;
58  }
59  /* Initializing a ref patterns */
61  /* Setting interpolation order */
63  /* Output file to store errors */
64  std::ofstream arq("Errors.txt", ios::app);
65  /* Create Cedric test instance */
66  TCedricTest cedric;
67  /* CedridTest stats */
68  cedric_rst.start();
69  /* Set parameters and run the test */
70  cedric.Run(nsub.get_value(), gcase.get_value(), porder.get_value(), 1, arq);
71  /* CedridTest stats */
72  cedric_rst.stop();
73 }
74 void UniformRefinement(const int nDiv, TPZGeoMesh *gmesh, const int dim, bool allmaterial, const int matidtodivided) {
76  for(int D=0; D<nDiv; D++)
77  {
78  int nels = gmesh->NElements();
79  for(int elem = 0; elem < nels; elem++)
80  {
81  TPZGeoEl * gel = gmesh->ElementVec()[elem];
82  if(!gel || gel->HasSubElement())
83  continue;
84  if(dim > 0 && gel->Dimension() != dim) continue;
85  if(!allmaterial) {
86  if(gel->MaterialId() == matidtodivided){
87  gel->Divide(filhos);
88  }
89  }
90  else{
91  gel->Divide(filhos);
92  }
93 #ifdef PZDEBUG
94  REAL volgel = fabs(gel->Volume());
95  REAL sumvol = 0.;
96  for(int nsubs=0;nsubs<gel->NSubElements();nsubs++)
97  sumvol += fabs(filhos[nsubs]->Volume());
98  if(!IsZero(volgel-sumvol)) {
99  std::cout << "Division of geometric element " << elem << " is wrong.\n";
100  DebugStop();
101  }
102 #endif
103  }
104  }
105  gmesh->ResetConnectivities();
106  gmesh->BuildConnectivity();
107 }
Contains a class to record running statistics on CSV tables.
static void SetgOrder(int order)
Sets the value of the default interpolation order.
Definition: pzcompel.h:825
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
Definition: tfadfunc.h:140
REAL Volume()
Return the volume of the element.
Definition: pzgeoel.cpp:1052
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
Definition: pzreal.h:668
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 InitializeAllUniformRefPatterns()
Initialize the uniform refinement pattern from hard coaded data for all linear geometric elements...
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
int MaterialId() const
Returns the material index of the element.
Definition: pzgeoel.h:250
Contains declaration of TPZCompEl class which defines the interface of a computational element...
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
virtual void Divide(TPZVec< TPZGeoEl *> &pv)
Divides the element and puts the resulting elements in the vector.
Definition: pzgeoel.h:742
void Run(int nsubdivisions, int geocase, int POrder, int MaterialId, std::ostream &out=std::cout)
Definition: CedricTest.cpp:246
TPZRefPatternDataBase gRefDBase
External variable to data base of patterns.
RunStatsTable cedric_rst("-ced_rdt", "TCedric::Run statistics raw data table.")
clarg::argInt porder("-p", "porder", 2)
clarg::argInt gcase("-g", "gcase", 1)
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
clarg::argBool help("-h", "display the help message")
clarg::argInt nsub("-nsub", "number of substructures", 15)
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
int parse_arguments(int argc, char *argv[])
Definition: arglib.cpp:195
void arguments_descriptions(ostream &os, string prefix, string suffix)
Definition: arglib.cpp:189
virtual int HasSubElement() const =0
Return 1 if the element has subelements.
void usage(char *prg)
Definition: main.cpp:19
void BuildConnectivity()
Build the connectivity of the grid.
Definition: pzgmesh.cpp:967
std::ofstream arq("Param.dat")
Output file with number of iteration made.
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.
void UniformRefinement(const int nDiv, TPZGeoMesh *gmesh, const int dim, bool allmaterial=false, const int matidtodivided=1)
Definition: main.cpp:74
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
const T & get_value() const
Definition: arglib.h:177
void ResetConnectivities()
Reset all connectivities.
Definition: pzgmesh.cpp:1576
virtual int NSubElements() const =0
Returns the number of subelements of the element independent of the fact whether the element has alr...
int main()
Definition: main.cpp:60
Contains the TPZRefPatternTools class which defines tools of pattern.
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138