SundanceVerboseFieldWriter.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
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 

Site Contact