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