Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #if defined (ALBANY_LCM) && defined(ALBANY_ZOLTAN)
00011
00012 #include <iomanip>
00013 #include <Teuchos_CommandLineProcessor.hpp>
00014
00015 #include <LCMPartition.h>
00016
00017 int main(int ac, char* av[])
00018 {
00019
00020
00021
00022 Teuchos::GlobalMPISession mpiSession(&ac, &av);
00023 Teuchos::CommandLineProcessor
00024 command_line_processor;
00025
00026 command_line_processor.setDocString(
00027 "Computation of connected components of an Exodus mesh.\n");
00028
00029 std::string input_file = "input.e";
00030 command_line_processor.setOption(
00031 "input",
00032 &input_file,
00033 "Input File Name");
00034
00035 std::string output_file = "output.e";
00036 command_line_processor.setOption(
00037 "output",
00038 &output_file,
00039 "Output File Name");
00040
00041
00042 command_line_processor.recogniseAllOptions(true);
00043
00044
00045 command_line_processor.throwExceptions(false);
00046
00047
00048 Teuchos::CommandLineProcessor::EParseCommandLineReturn
00049 parse_return = command_line_processor.parse(ac, av);
00050
00051 if (parse_return == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED) {
00052 return 0;
00053 }
00054
00055 if (parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
00056 return 1;
00057 }
00058
00059
00060
00061
00062 LCM::ConnectivityArray
00063 connectivity_array(input_file, output_file);
00064
00065
00066
00067
00068 LCM::DualGraph dual_graph(connectivity_array);
00069
00070
00071
00072
00073 std::vector<int>
00074 components;
00075
00076 const int
00077 number_components = dual_graph.GetConnectedComponents(components);
00078
00079
00080
00081 Albany::AbstractDiscretization &
00082 discretization = connectivity_array.GetDiscretization();
00083
00084 Albany::STKDiscretization &
00085 stk_discretization = static_cast<Albany::STKDiscretization &>(discretization);
00086
00087
00088 Albany::MDArray
00089 stk_component =
00090 stk_discretization.getStateArrays().elemStateArrays[0]["Partition"];
00091
00092
00093
00094
00095
00096
00097 for (std::vector<int>::size_type element = 0;
00098 element < components.size();
00099 ++element) {
00100 const int component = components[element];
00101
00102
00103 stk_component[element] = component;
00104
00105 }
00106
00107
00108 Teuchos::RCP<Epetra_Vector>
00109 solution_field = stk_discretization.getSolutionField();
00110
00111
00112
00113 stk_discretization.writeSolution(*solution_field, 1.0);
00114
00115 const int
00116 number_elements = connectivity_array.GetNumberElements();
00117
00118 std::cout << std::endl;
00119 std::cout << "==========================================";
00120 std::cout << std::endl;
00121 std::cout << "Number of Elements : " << number_elements << std::endl;
00122 std::cout << std::endl;
00123 std::cout << "Number of Mesh Components : " << number_components << std::endl;
00124 std::cout << "------------------------------------------";
00125 std::cout << std::endl;
00126 std::cout << "Element Component";
00127 std::cout << std::endl;
00128 std::cout << "------------------------------------------";
00129 std::cout << std::endl;
00130
00131 for (std::vector<int>::size_type element = 0;
00132 element < components.size();
00133 ++element) {
00134 std::cout << std::setw(8) << element;
00135 std::cout << std::setw(8) << components[element] << std::endl;
00136 }
00137
00138 std::cout << "==========================================";
00139 std::cout << std::endl;
00140
00141 return 0;
00142
00143 }
00144
00145 #else // #if defined (ALBANY_LCM) && defined(ALBANY_ZOLTAN)
00146
00147
00148 int main(int ac, char* av[])
00149 {
00150 return 0;
00151 }
00152
00153 #endif // #if defined (ALBANY_ZOLTAN)