12 #include "pz_config.h" 20 static LoggerPtr logger(Logger::getLogger(
"pz.refpattern.TPZRefPatternDataBase"));
51 std::map< MElementType , std::list< TPZAutoPointer<TPZRefPattern> > >::iterator mapIt;
52 std::list< TPZAutoPointer<TPZRefPattern> >::iterator listIt;
53 for(mapIt = fElTypeRefPatterns.begin(); mapIt != fElTypeRefPatterns.end(); mapIt++)
55 for(listIt = mapIt->second.begin(); listIt != mapIt->second.end(); listIt++)
57 Ids.insert((*listIt)->Id());
61 std::set<int>::iterator it;
64 for(
int id = 0;
id <= nRefPatterns;
id++)
80 std::ifstream in(filename.c_str());
81 ReadRefPatternDBase(in);
86 fElTypeRefPatterns.clear();
87 fIdRefPatterns.clear();
90 filename >> nRefpatterns;
91 for(
int i = 0; i < nRefpatterns; i++)
97 fElTypeRefPatterns[eltype].push_back(refP);
98 fIdRefPatterns[refP->
Id()] = refP;
105 filename << NRefPatterns() << std::endl ;
107 std::map< MElementType, std::list< TPZAutoPointer<TPZRefPattern> > >::iterator iterMap;
108 for (iterMap = fElTypeRefPatterns.begin(); iterMap != fElTypeRefPatterns.end(); iterMap++)
110 std::list<TPZAutoPointer<TPZRefPattern> > &refpList = (*iterMap).second;
111 std::list< TPZAutoPointer<TPZRefPattern> >::iterator refp;
112 for(refp = refpList.begin(); refp != refpList.end(); refp++)
123 std::string DefaulPath = PZSOURCEDIR;
125 DefaulPath +=
"/Refine/RefPatterns";
128 return ImportRefPatterns(DefaulPath, maxdim);
134 std::string bar =
"/";
136 std::string FileTypes (
"*.rpt");
137 std::string Command = std::string(
"ls -1 ") + Path + bar + FileTypes;
138 std::cout <<
"Generated command: " << Command.c_str() << std::endl;
142 fp = _popen(Command.c_str(),
"r");
145 fp = popen(Command.c_str(),
"r");
147 fp = (FILE *)open(Command.c_str(), O_RDONLY );
161 if( fgets(psBuffer,
sizeof(psBuffer), fp ) != NULL )
163 if (psBuffer[strlen(psBuffer)-1] ==
'\n')
165 psBuffer[strlen(psBuffer)-1] = 0;
167 std::cout <<
"Reading refinement patern file : " << psBuffer << std::endl;
168 std::string filref(psBuffer);
173 std::cout <<
"skipped\n";
177 if(!this->FindRefPattern(refpat))
179 this->InsertRefPattern(refpat);
203 std::list< TPZAutoPointer<TPZRefPattern> > ElTypeList = RefPatternList(type);
204 std::list< TPZAutoPointer<TPZRefPattern> >::iterator it;
206 std::string unifRefName;
211 unifRefName =
"UnifLin";
216 unifRefName =
"UnifTri";
221 unifRefName =
"UnifQua";
226 unifRefName =
"UnifTet";
231 unifRefName =
"UnifPyr";
236 unifRefName =
"UnifPri";
241 unifRefName =
"UnifHex";
251 for(it = ElTypeList.begin(); it != ElTypeList.end(); it++)
253 std::string compareRefrName = (*it)->
Name();
254 if( compareRefrName == unifRefName )
262 if(!UnifRefPat && type !=
EPoint)
264 std::cout <<
"Uniform refpattern " << unifRefName <<
" was not initialized!" << std::endl;
265 std::cout <<
"See " << __PRETTY_FUNCTION__ << std::endl;
283 std::cout <<
"inserting uniform refpattern: line\n";
293 std::istringstream str(buf);
298 InsertRefPattern(refpat);
310 std::cout <<
"inserting uniform refpattern: triangle\n";
325 std::istringstream str(buf);
330 InsertRefPattern(refpat);
342 std::cout <<
"inserting uniform refpattern: quadrilateral\n";
360 std::istringstream str(buf);
365 InsertRefPattern(refpat);
373 if (logger->isDebugEnabled()) {
374 std::stringstream sout;
384 std::cout <<
"inserting uniform refpattern: tetrahedra\n";
405 std::istringstream str(buf);
410 InsertRefPattern(refpat);
422 std::cout <<
"inserting uniform refpattern: pyramid\n";
446 " 5 5 9 12 11 10 13 " 451 std::istringstream str(buf);
456 InsertRefPattern(refpat);
468 std::cout <<
"inserting uniform refpattern: prism\n";
491 " 6 6 0 6 8 9 15 17 " 492 " 6 6 6 1 7 15 10 16 " 493 " 6 6 8 7 2 17 16 11 " 494 " 6 6 17 16 15 8 7 6 " 495 " 6 6 9 15 17 3 12 14 " 496 " 6 6 15 10 16 12 4 13 " 497 " 6 6 17 16 11 14 13 5 " 498 " 6 6 14 13 12 17 16 15 ";
499 std::istringstream str(buf);
504 InsertRefPattern(refpat);
516 std::cout <<
"inserting uniform refpattern: hexahedre\n";
547 "7 8 0 1 2 3 4 5 6 7 " 548 "7 8 0 8 20 11 12 21 26 24 " 549 "7 8 8 1 9 20 21 13 22 26 " 550 "7 8 20 9 2 10 26 22 14 23 " 551 "7 8 11 20 10 3 24 26 23 15 " 552 "7 8 12 21 26 24 4 16 25 19 " 553 "7 8 21 13 22 26 16 5 17 25 " 554 "7 8 26 22 14 23 25 17 6 18 " 555 "7 8 24 26 23 15 19 25 18 7 ";
556 std::istringstream str(buf);
561 InsertRefPattern(refpat);
573 cout <<
"Cant generate uniform refpattern because MElementType was not found on " << __PRETTY_FUNCTION__ << endl;
582 InitializeUniformRefPattern(
EOned);
587 InitializeUniformRefPattern(
EPrisma);
588 InitializeUniformRefPattern(
ECube);
594 std::string path = REFPATTERNDIR;
595 ImportRefPatterns(path, maxdim);
603 PZError <<
"TPZGeoMesh::InsertRefPattern ERROR : NULL refinement pattern! " << std::endl;
611 int id = ReturnUniqueId();
617 std::map< int , TPZAutoPointer<TPZRefPattern> >::iterator itid = fIdRefPatterns.find(refpat->
Id());
618 if(itid != fIdRefPatterns.end())
620 int id = ReturnUniqueId();
625 fElTypeRefPatterns[eltype].push_back(refpat);
626 fIdRefPatterns[refpat->
Id()] = refpat;
638 std::map< int, TPZAutoPointer<TPZRefPattern> >::iterator it;
639 for(it = fIdRefPatterns.begin(); it != fIdRefPatterns.end(); it++)
655 std::map< int , TPZAutoPointer<TPZRefPattern> >::iterator it;
657 it = fIdRefPatterns.find(
id);
659 if(it != fIdRefPatterns.end())
661 refPatReturned = it->second;
664 return refPatReturned;
672 std::map< int , TPZAutoPointer<TPZRefPattern> >::iterator it;
673 for(it = fIdRefPatterns.begin(); it != fIdRefPatterns.end(); it++)
675 if( (it->second)->fName == name)
688 return fElTypeRefPatterns[eltype];
694 int nRefPatterns = fIdRefPatterns.size();
702 std::map< MElementType , std::list< TPZAutoPointer<TPZRefPattern> > >::iterator it;
704 for(it = fElTypeRefPatterns.begin(); it != fElTypeRefPatterns.end(); it++)
706 out <<
"======================================================\n";
707 out <<
"**************************************************\n";
709 out <<
"**************************************************";
711 std::list< TPZAutoPointer<TPZRefPattern> >::iterator itt;
713 for(itt = it->second.begin(); itt != it->second.end(); itt++)
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 InitializeAllUniformRefPatterns()
Initialize the uniform refinement pattern from hard coaded data for all linear geometric elements...
void ReadAndCreateRefinementPattern(std::istream &file)
const std::list< TPZAutoPointer< TPZRefPattern > > & RefPatternList(MElementType eltype)
Return the complete set of refinement patterns availabe.
static const int fNonInitializedId
Id for identifying a non initialized pattern.
void InitializeUniformRefPattern(MElementType elType)
Initialize the uniform refinement pattern from hard coaded data for an specific geometric element...
void InsertRefPattern(TPZAutoPointer< TPZRefPattern > &refpat)
Insert the refinement pattern in the list of availabe refinement patterns assigns an Id to refPattern...
TPZGeoEl * Element(int iel)
It returns the element number iel from the stack of elements of the geometric mesh.
void SetId(int id)
Set the id of the refinement pattern.
std::string MElementType_Name(MElementType elType)
Returns the name of the element type.
void Print(std::ostream &out=std::cout)
void InsertPermuted()
Generate all permuted partitions and insert them in the mesh.
void InitializeRefPatterns(int maxdim=3)
TPZGeoMesh fRefPatternMesh
Geometric mesh which defines the topology of the current refinement pattern.
TPZAutoPointer< TPZRefPattern > FindRefPattern(TPZAutoPointer< TPZRefPattern > &refpat)
Check whether the refinement pattern already exists.
TPZRefPatternDataBase gRefDBase
External variable to data base of patterns.
Defines data base of patterns. Refine.
TPZAutoPointer< TPZRefPattern > GetUniformRefPattern(MElementType type)
Retrieves the uniform refinement pattern for given element type.
int Id() const
Return the id of the refinement pattern.
#define DebugStop()
Returns a message to user put a breakpoint in.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
virtual MElementType Type() const =0
Returns the element type acording to pzeltype.h.
int ImportRefPatterns(int maxdim=3)
Import a library of refinement patterns from the install directory.
void WriteRefPatternDBase(std::ofstream &fileout)
std::string Name()
Returns the refinement pattern identifier.
void ReadRefPatternDBase(const std::string &filename)
Read all refpatterns available in the given file.
Contains the TPZRefPatternDataBase class which defines data base of patterns.
Defines the topology of the current refinement pattern to a mesh. Refine.
int Dimension()
Get Dimension.
MElementType
Define the element types.
void SetName(std::string name)
Sets the name associated with the refinement pattern.
void PrintMore(std::ostream &out=std::cout) const
void WritePattern(std::ofstream &out) const
#define PZError
Defines the output device to error messages and the DebugStop() function.