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.e";
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 std::cout << "***********************" << std::endl;
00077 std::cout << "Before mesh subdivision" << std::endl;
00078 std::cout << "***********************" << std::endl;
00079 LCM::display_connectivity(topology.getBulkData(), topology.getCellRank());
00080
00081
00082 std::vector<int> vector_initial_entities = return_number_entities(topology);
00083
00084
00085
00086 topology.removeNodeRelations();
00087
00088
00089
00090
00091
00092 topology.barycentricSubdivision();
00093 std::cout << "*************************" << std::endl;
00094 std::cout << "After element subdivision" << std::endl;
00095 std::cout << "*************************" << std::endl;
00096
00097 std::vector<int> vector_final_entities = return_number_entities(topology);
00098 LCM::display_connectivity(topology.getBulkData(), topology.getCellRank());
00099
00100
00101 std::cout << "*************************************" << std::endl;
00102 std::cout << "Checking final mesh after subdivision" << std::endl;
00103 std::cout << "*************************************" << std::endl;
00104 std::cout <<verify_subdivision(vector_initial_entities,
00105 vector_final_entities)<<std::endl;
00106
00107 return 0;
00108
00109 }
00110
00111
00112
00113
00114
00115
00116 std::vector<int>
00117 return_number_entities(LCM::Topology & topology_){
00118
00119 std::vector<int> output_vector;
00120
00121 stk::mesh::BulkData* bulkData_ = topology_.getBulkData();
00122 std::vector<Entity*> initial_entities_D0 = topology_.getEntitiesByRank(
00123 *(bulkData_), 0);
00124 output_vector.push_back(initial_entities_D0.size());
00125
00126 std::vector<Entity*> initial_entities_D1 = topology_.getEntitiesByRank(
00127 *(bulkData_), 1);
00128 output_vector.push_back(initial_entities_D1.size());
00129
00130 std::vector<Entity*> initial_entities_D2 = topology_.getEntitiesByRank(
00131 *(bulkData_), 2);
00132 output_vector.push_back(initial_entities_D2.size());
00133
00134 std::vector<Entity*> initial_entities_D3 = topology_.getEntitiesByRank(
00135 *(bulkData_), 3);
00136 output_vector.push_back(initial_entities_D3.size());
00137
00138 return output_vector;
00139 }
00140
00141
00142
00143 std::string
00144 verify_subdivision(const std::vector<int> & former_num_entities,
00145 const std::vector<int> & final_num_entities){
00146
00147 int final_number_nodes = former_num_entities[0]+ former_num_entities[1]+ former_num_entities[2]+
00148 former_num_entities[3];
00149 TEUCHOS_TEST_FOR_EXCEPTION( final_number_nodes != final_num_entities[0], std::logic_error,
00150 "The number of nodes after subdivision is incorrect\n");
00151
00152 int final_number_edges = (former_num_entities[1]*2)+(former_num_entities[2]*6)+
00153 (14*former_num_entities[3]);
00154 TEUCHOS_TEST_FOR_EXCEPTION( final_number_edges != final_num_entities[1], std::logic_error,
00155 "The number of edges after subdivision is incorrect\n");
00156
00157 int final_number_faces = (former_num_entities[2]*6)+(36* former_num_entities[3]);
00158 TEUCHOS_TEST_FOR_EXCEPTION( final_number_faces != final_num_entities[2], std::logic_error,
00159 "The number of faces after subdivision is incorrect\n");
00160
00161 int final_number_elements = 24* former_num_entities[3];
00162 TEUCHOS_TEST_FOR_EXCEPTION( final_number_elements != final_num_entities[3], std::logic_error,
00163 "The number of elements after subdivision is incorrect\n");
00164
00165 return std::string("SUBDIVISION TEST 1: PASSED");
00166 }