00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "SundanceVerboseFieldWriter.hpp"
00032 #include "PlayaExceptions.hpp"
00033 #include "SundanceOut.hpp"
00034 #include "PlayaTabs.hpp"
00035
00036
00037 using namespace Sundance;
00038 using namespace Teuchos;
00039
00040
00041 void VerboseFieldWriter::write() const
00042 {
00043 int nProc = mesh().comm().getNProc();
00044 int myRank = mesh().comm().getRank();
00045
00046 RCP<std::ostream> osp;
00047 if (filename().length()==0)
00048 {
00049 osp = rcp(&std::cout, false);
00050 }
00051 else
00052 {
00053 std::string f = filename() + ".txt";
00054 if (nProc > 1) f = f + "." + Teuchos::toString(myRank);
00055 osp = rcp(new std::ofstream(f.c_str()));
00056 }
00057 std::ostream& os = *osp;
00058
00059 if (myRank==0) os << "VerboseFieldWriter output" << std::endl;
00060 for (int p=0; p<nProc; p++)
00061 {
00062 mesh().comm().synchronize();
00063 mesh().comm().synchronize();
00064 mesh().comm().synchronize();
00065 if (p != myRank) continue;
00066 os << "======== processor " << p << " ============================ "
00067 << std::endl;
00068 Tabs tab0;
00069 int dim = mesh().spatialDim();
00070 int nPts = mesh().numCells(0);
00071 int nElems = mesh().numCells(dim);
00072 os << tab0 << "spatial dimension = " << dim << std::endl;
00073 os << tab0 << "num points = " << nPts << std::endl;
00074 os << tab0 << "num elements = " << nElems << std::endl;
00075 os << tab0 << "Point list: " << std::endl;
00076
00077 int dummy;
00078 for (int i=0; i<nPts; i++)
00079 {
00080 Tabs tab1;
00081 os << tab1 << "L=" << i
00082 << " G=" << mesh().mapLIDToGID(0, i)
00083 << " x=" << mesh().nodePosition(i)
00084 << " owner=" << mesh().ownerProcID(0,i)
00085 << " label=" << mesh().label(0,i) << std::endl;
00086 int nc = mesh().numMaxCofacets(0,i);
00087 Tabs tab2;
00088 os << tab2 << "num cofacets=" << nc << " cofs = {";
00089 for (int c=0; c<nc; c++)
00090 {
00091 if (c==0) os << " " ;
00092 else os << ", ";
00093 os << mesh().mapLIDToGID(dim, mesh().maxCofacetLID(0,i,c,dummy));
00094 }
00095 os << "}" << std::endl;
00096 }
00097
00098
00099 os << tab0 << "Element list: " << std::endl;
00100
00101 for (int i=0; i<nElems; i++)
00102 {
00103 int facetSign;
00104 Tabs tab1;
00105 os << tab1 << "L=" << i
00106 << " G=" << mesh().mapLIDToGID(dim, i)
00107 << ", nodes L={";
00108 int numNodes = mesh().numFacets(dim, i, 0);
00109 for (int j=0; j<numNodes; j++)
00110 {
00111 if (j != 0) os << ", ";
00112 os << mesh().facetLID(dim, i, 0, j, facetSign);
00113 }
00114 os << "}, G={";
00115 for (int j=0; j<numNodes; j++)
00116 {
00117 if (j != 0) os << ", ";
00118 os << mesh().mapLIDToGID(0, mesh().facetLID(dim, i, 0, j, facetSign));
00119 }
00120 os << "}, owner=" << mesh().ownerProcID(dim,i)
00121 << ", label=" << mesh().label(dim,i) << std::endl;
00122 for (int fd=1; fd<dim; fd++)
00123 {
00124 Tabs tab2;
00125 os << tab2 << "facets of dimension " << fd << std::endl;
00126 int nf = mesh().numFacets(dim, i, fd);
00127 for (int f=0; f<nf; f++)
00128 {
00129
00130 Tabs tab3;
00131 int flid = mesh().facetLID(dim, i, fd, f, facetSign);
00132 int fgid = -1;
00133 int fowner = -1;
00134 if (mesh().hasIntermediateGIDs(fd))
00135 {
00136 fgid = mesh().mapLIDToGID(fd, flid);
00137 fowner = mesh().ownerProcID(fd, flid);
00138 }
00139 os << tab3 << "f#=" << f << " L=" << flid
00140 << " G=" << fgid << " owner=" << fowner
00141 << " nodes={";
00142 int nfn = mesh().numFacets(fd, flid, 0);
00143 for (int fn=0; fn<nfn; fn++)
00144 {
00145 if (fn != 0) os << ", ";
00146 os << mesh().facetLID(fd, flid, 0, fn, facetSign);
00147 }
00148 os << "} sign=" << facetSign;
00149 os << " label=" << mesh().label(fd,flid) << std::endl;
00150 }
00151
00152 }
00153 }
00154
00155 }
00156 }
00157
00158
00159