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

Site Contact