Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "time.h"
00012
00013 #include "topology/Topology.h"
00014 #include "topology/Topology_Utils.h"
00015
00016 typedef stk::mesh::Entity Entity;
00017
00018
00019
00020
00021
00022
00023 std::vector<int>
00024 return_number_entities(LCM::Topology & topology_);
00025
00026
00027
00028
00029 std::string
00030 verify_subdivision(const std::vector<int> & former_num_entities,
00031 const std::vector<int> & final_num_entities);
00032
00033 int main(int ac, char* av[])
00034 {
00035
00036
00037
00038
00039 Teuchos::CommandLineProcessor command_line_processor;
00040
00041 command_line_processor.setDocString("Test of barycentric subdivision.\n"
00042 "Reads in a mesh and applies the barycentric subdivision algorithm.\n"
00043 "Restricted to simplicial complexes.\n");
00044
00045 std::string input_file = "input.e";
00046 command_line_processor.setOption("input", &input_file, "Input File Name");
00047
00048 std::string output_file = "output.exo";
00049 command_line_processor.setOption("output", &output_file, "Output File Name");
00050
00051
00052 command_line_processor.recogniseAllOptions(true);
00053
00054
00055 command_line_processor.throwExceptions(false);
00056
00057
00058 Teuchos::CommandLineProcessor::EParseCommandLineReturn parse_return =
00059 command_line_processor.parse(ac, av);
00060
00061 if (parse_return == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED) {
00062 return 0;
00063 }
00064
00065 if (parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
00066 return 1;
00067 }
00068
00069
00070
00071
00072
00073 Teuchos::GlobalMPISession mpiSession(&ac, &av);
00074 LCM::Topology topology(input_file, output_file);
00075
00076
00077 std::cout << "***********************" << std::endl;
00078 std::cout << "Before mesh subdivision" << std::endl;
00079 std::cout << "***********************" << std::endl;
00080 LCM::display_connectivity(topology.getBulkData(), topology.getCellRank());
00081
00082 std::vector<int> vector_initial_entities = return_number_entities(topology);
00083
00084
00085 topology.removeNodeRelations();
00086
00087
00088
00089
00090
00091 topology.barycentricSubdivision();
00092 std::cout << "*************************" << std::endl;
00093 std::cout << "After element subdivision" << std::endl;
00094 std::cout << "*************************" << std::endl;
00095
00096
00097
00098
00099 topology.restoreElementToNodeConnectivity();
00100 LCM::display_connectivity(topology.getBulkData(), topology.getCellRank());
00101
00102
00103
00104
00105 Teuchos::RCP<Albany::AbstractDiscretization> discretization_ptr =
00106 topology.getDiscretization();
00107 Albany::STKDiscretization & stk_discretization =
00108 static_cast<Albany::STKDiscretization &>(*discretization_ptr);
00109 Teuchos::RCP<Epetra_Vector> solution_field =
00110 stk_discretization.getSolutionField();
00111
00112
00113
00114 stk_discretization.writeSolution(*solution_field, 1.0);
00115
00116
00117
00118
00119 std::cout << "*************************************" << std::endl;
00120 std::cout << "Checking final mesh after subdivision" << std::endl;
00121 std::cout << "*************************************" << std::endl;
00122 std::string no_use_file = "output.exo";
00123 LCM::Topology topology2(output_file, no_use_file);
00124 std::vector<int> vector_final_entities = return_number_entities(topology2);
00125 std::cout <<verify_subdivision(vector_initial_entities,
00126 vector_final_entities)<<std::endl;
00127
00128 return 0;
00129 }
00130
00131
00132
00133
00134
00135 std::vector<int>
00136 return_number_entities(LCM::Topology & topology_){
00137
00138 std::vector<int> output_vector;
00139
00140 stk::mesh::BulkData* bulkData_ = topology_.getBulkData();
00141 std::vector<Entity*> initial_entities_D0 = topology_.getEntitiesByRank(
00142 *(bulkData_), 0);
00143 output_vector.push_back(initial_entities_D0.size());
00144
00145 std::vector<Entity*> initial_entities_D1 = topology_.getEntitiesByRank(
00146 *(bulkData_), 1);
00147 output_vector.push_back(initial_entities_D1.size());
00148
00149 std::vector<Entity*> initial_entities_D2 = topology_.getEntitiesByRank(
00150 *(bulkData_), 2);
00151 output_vector.push_back(initial_entities_D2.size());
00152
00153 std::vector<Entity*> initial_entities_D3 = topology_.getEntitiesByRank(
00154 *(bulkData_), 3);
00155 output_vector.push_back(initial_entities_D3.size());
00156
00157 return output_vector;
00158 }
00159
00160
00161
00162 std::string
00163 verify_subdivision(const std::vector<int> & former_num_entities,
00164 const std::vector<int> & final_num_entities){
00165
00166 int final_number_nodes = former_num_entities[0]+ former_num_entities[1]+ former_num_entities[2]+
00167 former_num_entities[3];
00168 TEUCHOS_TEST_FOR_EXCEPTION( final_number_nodes != final_num_entities[0], std::logic_error,
00169 "The number of nodes after subdivision is incorrect\n");
00170
00171 int final_number_edges = (former_num_entities[1]*2)+(former_num_entities[2]*6)+
00172 (14*former_num_entities[3]);
00173 TEUCHOS_TEST_FOR_EXCEPTION( final_number_edges != final_num_entities[1], std::logic_error,
00174 "The number of edges after subdivision is incorrect\n");
00175
00176 int final_number_faces = (former_num_entities[2]*6)+(36* former_num_entities[3]);
00177 TEUCHOS_TEST_FOR_EXCEPTION( final_number_faces != final_num_entities[2], std::logic_error,
00178 "The number of faces after subdivision is incorrect\n");
00179
00180 int final_number_elements = 24* former_num_entities[3];
00181 TEUCHOS_TEST_FOR_EXCEPTION( final_number_elements != final_num_entities[3], std::logic_error,
00182 "The number of elements after subdivision is incorrect\n");
00183
00184 return std::string("SUBDIVISION TEST 2: PASSED");
00185 }