00001 #include "SundanceMeshSourceBase.hpp"
00002 #include "PlayaTabs.hpp"
00003 #include "SundanceOut.hpp"
00004 #include "SundanceBasicSimplicialMeshType.hpp"
00005
00006 using namespace Sundance;
00007 using namespace Sundance;
00008
00009 using namespace Teuchos;
00010 using namespace Sundance;
00011
00012
00013 MeshSourceBase::MeshSourceBase(const MeshType& meshType,
00014 const MPIComm& comm)
00015 : cachedMesh_(),
00016 hasCachedMesh_(),
00017 meshType_(meshType),
00018 comm_(comm),
00019 elemAttributes_(rcp(new Array<Array<double> >())),
00020 nodeAttributes_(rcp(new Array<Array<double> >()))
00021 {
00022 }
00023
00024 MeshSourceBase::MeshSourceBase(const ParameterList& params)
00025 : cachedMesh_(),
00026 hasCachedMesh_(),
00027 meshType_(new BasicSimplicialMeshType()),
00028 comm_(MPIComm::world()),
00029 elemAttributes_(rcp(new Array<Array<double> >())),
00030 nodeAttributes_(rcp(new Array<Array<double> >()))
00031 {
00032
00033 }
00034
00035 Mesh MeshSourceBase::getMesh() const
00036 {
00037 Tabs tabs;
00038
00039
00040 if (!hasCachedMesh_)
00041 {
00042 Mesh rtn = fillMesh();
00043 if (verb() > 0)
00044 {
00045 std::cerr << tabs << "got a mesh with " << rtn.numCells(0)
00046 << " nodes and " << rtn.numCells(rtn.spatialDim())
00047 << " maximal cells" << std::endl;
00048 }
00049 return rtn;
00050 }
00051 return cachedMesh_;
00052 }
00053
00054 void MeshSourceBase
00055 ::getAttributes(RCP<Array<Array<double> > >& nodeAttributes,
00056 RCP<Array<Array<double> > >& elemAttributes) const
00057 {
00058 nodeAttributes = nodeAttributes_;
00059 elemAttributes = elemAttributes_;
00060 }
00061
00062 Mesh MeshSourceBase::createMesh(int dim) const
00063 {
00064 cachedMesh_ = meshType_.createEmptyMesh(dim, comm_);
00065 cachedMesh_.ptr()->setVerb(verb());
00066 hasCachedMesh_ = true;
00067
00068 return cachedMesh_;
00069 }