Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "topology/Topology.h"
00011 #include "topology/Topology_Utils.h"
00012
00013 int main(int ac, char* av[])
00014 {
00015
00016
00017
00018
00019 Teuchos::CommandLineProcessor
00020 command_line_processor;
00021
00022 command_line_processor.setDocString(
00023 "Test of element separation through nodal insertion.\n"
00024 "Remove and replace all nodes in elements.\n");
00025
00026 std::string input_file = "input.e";
00027 command_line_processor.setOption(
00028 "input",
00029 &input_file,
00030 "Input File Name");
00031
00032 std::string output_file = "output.e";
00033 command_line_processor.setOption(
00034 "output",
00035 &output_file,
00036 "Output File Name");
00037
00038
00039 command_line_processor.recogniseAllOptions(true);
00040
00041
00042 command_line_processor.throwExceptions(false);
00043
00044
00045 Teuchos::CommandLineProcessor::EParseCommandLineReturn
00046 parse_return = command_line_processor.parse(ac, av);
00047
00048 if (parse_return == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED) {
00049 return 0;
00050 }
00051
00052 if (parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
00053 return 1;
00054 }
00055
00056
00057
00058
00059
00060 Teuchos::GlobalMPISession mpiSession(&ac,&av);
00061
00062 LCM::Topology
00063 topology(input_file,output_file);
00064
00065 stk::mesh::BulkData&
00066 bulkData = *(topology.getBulkData());
00067
00068
00069
00070
00071
00072
00073 std::cout << "*************************\n"
00074 << "Before element separation\n"
00075 << "*************************\n";
00076
00077
00078
00079
00080 std::vector<stk::mesh::Entity*> element_lst;
00081 stk::mesh::get_entities(bulkData,topology.getCellRank(),element_lst);
00082
00083
00084
00085 topology.removeNodeRelations();
00086
00087
00088 std::map<stk::mesh::EntityKey, bool> entity_open;
00089 topology.setEntitiesOpen(entity_open);
00090 std::string gviz_output = LCM::parallelize_string("output") + ".dot";
00091 topology.outputToGraphviz(gviz_output);
00092
00093
00094 bulkData.modification_begin();
00095
00096
00097 std::cout << "begin mesh fracture\n";
00098 topology.splitOpenFaces(entity_open);
00099
00100
00101
00102
00103
00104
00105 topology.restoreElementToNodeConnectivity();
00106
00107
00108 bulkData.modification_end();
00109
00110
00111 std::cout << "*************************\n"
00112 << "After element separation\n"
00113 << "*************************\n";
00114
00115
00116
00117
00118 Teuchos::RCP<Albany::AbstractDiscretization> discretization_ptr =
00119 topology.getDiscretization();
00120 Albany::STKDiscretization & stk_discretization =
00121 static_cast<Albany::STKDiscretization &>(*discretization_ptr);
00122
00123 Teuchos::ArrayRCP<double>
00124 coordinates = stk_discretization.getCoordinates();
00125
00126
00127
00128
00129
00130 Teuchos::RCP<const Epetra_Map> dof_map = stk_discretization.getMap();
00131 Epetra_Vector displacement = Epetra_Vector(*(dof_map),true);
00132
00133
00134 stk::mesh::get_entities(bulkData,topology.getCellRank(),element_lst);
00135
00136
00137 double alpha = 0.5;
00138
00139 for (int i = 0; i < element_lst.size(); ++i){
00140 std::vector<double> centroid(3);
00141 std::vector<double> disp(3);
00142 stk::mesh::PairIterRelation relations =
00143 element_lst[i]->relations(LCM::NODE_RANK);
00144
00145 for (int j = 0; j < relations.size(); ++j){
00146 stk::mesh::Entity & node = *(relations[j].entity());
00147 int id = static_cast<int>(node.identifier());
00148 centroid[0] += coordinates[id*3-3];
00149 centroid[1] += coordinates[id*3-2];
00150 centroid[2] += coordinates[id*3-1];
00151 }
00152 centroid[0] /= relations.size();
00153 centroid[1] /= relations.size();
00154 centroid[2] /= relations.size();
00155
00156
00157 for (int j = 0; j < 3; ++j){
00158 disp[j] = alpha*centroid[j];
00159 }
00160
00161
00162 for (int j = 0; j < relations.size(); ++j){
00163 stk::mesh::Entity & node = *(relations[j].entity());
00164 int id = static_cast<int>(node.identifier());
00165 displacement[id*3-3] += disp[0];
00166 displacement[id*3-2] += disp[1];
00167 displacement[id*3-1] += disp[2];
00168 }
00169 }
00170
00171 stk_discretization.setResidualField(displacement);
00172
00173 Teuchos::RCP<Epetra_Vector>
00174 solution_field = stk_discretization.getSolutionField();
00175
00176
00177
00178
00179 stk_discretization.writeSolution(*solution_field, 1.0);
00180
00181 return 0;
00182
00183 }