00001 #include "SundanceMeshSource.hpp" 00002 #include "SundanceOut.hpp" 00003 #include "SundanceBasicSimplicialMeshType.hpp" 00004 #include "SundanceMeshType.hpp" 00005 #include "PlayaTabs.hpp" 00006 #include "Teuchos_Time.hpp" 00007 #include "Teuchos_TimeMonitor.hpp" 00008 00009 using namespace Teuchos; 00010 using namespace Sundance; 00011 using Playa::Handle; 00012 using Playa::Handleable; 00013 00014 00015 static Time& getMeshTimer() 00016 { 00017 static RCP<Time> rtn 00018 = TimeMonitor::getNewTimer("get mesh"); 00019 return *rtn; 00020 } 00021 00022 MeshSource::MeshSource() 00023 : Handle<MeshSourceBase>() 00024 {} 00025 00026 MeshSource::MeshSource(Handleable<MeshSourceBase>* rawPtr) 00027 : Handle<MeshSourceBase>(rawPtr) 00028 {} 00029 00030 00031 MeshSource::MeshSource(const RCP<MeshSourceBase>& smartPtr) 00032 : Handle<MeshSourceBase>(smartPtr) 00033 {} 00034 00035 Mesh MeshSource::getMesh() const 00036 { 00037 TimeMonitor timer(getMeshTimer()); 00038 00039 Mesh rtn; 00040 try 00041 { 00042 Tabs tabs; 00043 int nProc = ptr()->comm().getNProc(); 00044 SUNDANCE_OUT(ptr()->verb() > 0, 00045 "MeshSource::getMesh()"); 00046 if (staggerOutput() && nProc > 1) 00047 { 00048 int myRank = ptr()->comm().getRank(); 00049 for (int p=0; p<nProc; p++) 00050 { 00051 ptr()->comm().synchronize(); 00052 if (p != myRank) continue; 00053 SUNDANCE_OUT(ptr()->verb() > 0, 00054 "========= Building local mesh on processor " 00055 << p << " ============ "); 00056 rtn = ptr()->getMesh(); 00057 } 00058 } 00059 else 00060 { 00061 rtn = ptr()->getMesh(); 00062 } 00063 00064 if (rtn.spatialDim() > 1) rtn.assignIntermediateCellGIDs(1); 00065 if (rtn.spatialDim() > 2) rtn.assignIntermediateCellGIDs(2); 00066 } 00067 catch(std::exception& e) 00068 { 00069 SUNDANCE_TRACE(e); 00070 } 00071 return rtn; 00072 } 00073 00074 void MeshSource::getAttributes(RCP<Array<Array<double> > >& nodeAttributes, 00075 RCP<Array<Array<double> > >& elemAttributes) const 00076 { 00077 getMesh(); 00078 ptr()->getAttributes(nodeAttributes, elemAttributes); 00079 } 00080 00081 00082 MeshType& MeshSource::defaultMeshType() 00083 { 00084 static MeshType rtn = new BasicSimplicialMeshType(); 00085 return rtn; 00086 } 00087 00088 const MPIComm& MeshSource::comm() const 00089 { 00090 return ptr()->comm(); 00091 }