• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Practice.cc

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 // Test of barycentric subdivision.
00007 // Reads in a mesh and applies the barycentric subdivision algorithm
00008 // to it. Restricted to simplicial complexes.
00009 //
00010 
00011 #include "topology/Topology.h"
00012 #include "time.h"
00013 int main(int ac, char* av[])
00014 {
00015 
00016   //
00017   // Create a command line processor and parse command line options
00018   //
00019   Teuchos::CommandLineProcessor command_line_processor;
00020 
00021   command_line_processor.setDocString("Test of barycentric subdivision.\n"
00022       "Reads in a mesh and applies the barycentric subdivision algorithm.\n"
00023       "Restricted to simplicial complexes.\n");
00024 
00025   std::string input_file = "input.e";
00026   command_line_processor.setOption("input", &input_file, "Input File Name");
00027 
00028   std::string output_file = "output.e";
00029   command_line_processor.setOption("output", &output_file, "Output File Name");
00030 
00031   // Throw a warning and not error for unrecognized options
00032   command_line_processor.recogniseAllOptions(true);
00033 
00034   // Don't throw exceptions for errors
00035   command_line_processor.throwExceptions(false);
00036 
00037   // Parse command line
00038   Teuchos::CommandLineProcessor::EParseCommandLineReturn parse_return =
00039   command_line_processor.parse(ac, av);
00040 
00041   if (parse_return == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED) {
00042     return 0;
00043   }
00044 
00045   if (parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
00046     return 1;
00047   }
00048 
00049   //
00050   // Read the mesh
00051   //
00052   // Copied from Partition.cc
00053   Teuchos::GlobalMPISession mpiSession(&ac, &av);
00054 
00055   LCM::Topology topology(input_file, output_file);
00056 
00057   // Node rank should be 0 and element rank should be equal to the dimension of the
00058   //system (e.g. 2 for 2D meshes and 3 for 3D meshes)
00059   //cout << "Node Rank: "<< nodeRank << ", Element Rank: " << elementRank << "\n";
00060 
00061   // Print element connectivity before the mesh topology is modified
00062   std::cout << "***********************" << std::endl;
00063   std::cout << "Before mesh subdivision" << std::endl;
00064   std::cout << "***********************" << std::endl;
00065 
00066  // topology.display_connectivity(topology);
00067 
00068   // Start the mesh update process
00069   // Prepares mesh for barycentric subdivision
00070   topology.removeNodeRelations();
00071 
00072   // Output graph structure for debugging
00073   std::string gviz_output = "before.dot";
00074   topology.outputToGraphviz(gviz_output);
00075 
00076   //
00077   // Here starts the barycentric subdivision.
00078   //
00079   //-----------------------------------------------------------------------------------------------------------------------------------
00080   // Generate the output file
00081   //-----------------------------------------------------------------------------------------------------------------------------------
00082 
00083   //Measure the time computing the barycentric subdivision
00084   clock_t start, end;
00085   double cpu_time_used;
00086   start = clock();
00087 
00088   //Carry out barycentric subdivision on the mesh
00089   topology.barycentricSubdivision_();
00090 
00091   end = clock();
00092   cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
00093 
00094   std::cout << "*************************" << std::endl;
00095   std::cout << "After element subdivision" << std::endl;
00096   std::cout << "*************************" << std::endl;
00097   gviz_output = "after.dot";
00098   topology.outputToGraphviz(gviz_output);
00099 
00100 
00101   /*
00102   // Recreates connectivity in stk mesh expected by Albany_STKDiscretization
00103   // Must be called each time at conclusion of mesh modification
00104   topology.restoreElementToNodeConnectivity();
00105   topology.displayConnectivity();
00106   std::cout << std::endl;
00107   std::cout << "topology.barycentricSubdivision() takes "
00108       << cpu_time_used << " seconds"<< std::endl;
00109 
00110   Teuchos::RCP<Albany::AbstractDiscretization> discretization_ptr =
00111       topology.getDiscretization();
00112   Albany::STKDiscretization & stk_discretization =
00113       static_cast<Albany::STKDiscretization &>(*discretization_ptr);
00114 
00115   Teuchos::RCP<Epetra_Vector> solution_field =
00116       stk_discretization.getSolutionField();
00117 
00118   // Write final mesh to exodus file
00119   // second arg to output is (pseudo)time
00120 //  stk_discretization.outputToExodus(*solution_field, 1.0);
00121   stk_discretization.writeSolution(*solution_field, 1.0);
00122 */
00123   return 0;
00124 
00125 }
00126 
00127 
00128 

Generated on Wed Mar 26 2014 18:36:43 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1