MeshKit
1.0
|
00001 #include "meshkit/PostBL.hpp" 00002 namespace MeshKit 00003 { 00004 int PostBL::push_bulk_mesh(VerdictWrapper vw) 00005 // --------------------------------------------------------------------------- 00009 // --------------------------------------------------------------------------- 00010 { 00011 // swap nodal coordinates of input nodes with innermost BL nodes to push the bulk mesh 00012 int count = -1; 00013 00014 int matindx = -1; 00015 for (Range::iterator kter = nodes.begin(); kter != nodes.end(); ++kter){ 00016 ++count; 00017 if(all_bl[count] == 0 ){ 00018 00019 int nid = (count+1)*m_Intervals - 1; 00020 MBERRCHK(mb->get_coords(&new_vert[nid], 1, coords_new_quad),mb); 00021 MBERRCHK(mb->get_coords(&(*kter), 1, coords_old_quad),mb); 00022 00023 //TODO: Set connectivity for pushed hexes 00024 if (debug) { 00025 m_LogFile << std::setprecision (3) << std::scientific << " : NID: " << (nid) 00026 << coords_old_quad[0] 00027 << ", " << coords_old_quad[1] << ", " << coords_old_quad[2] << " OLD:- coords: NEW" << coords_new_quad[0] 00028 << ", " << coords_new_quad[1] << ", " << coords_new_quad[2] << std::endl; 00029 } 00030 moab::Range deformed_hex; 00031 MBERRCHK(mb->get_adjacencies(&(*kter), 1, m_GD, false, deformed_hex, Interface::UNION), mb); 00032 std::vector<moab::EntityHandle> dhex_conn; 00033 for(Range::iterator fmter = deformed_hex.begin(); fmter != deformed_hex.end(); ++fmter){ 00034 mb->get_connectivity(&(*fmter), 1, dhex_conn); 00035 if(dhex_conn.size () > 0){ 00036 for(int i=0; i < (int)dhex_conn.size(); i++){ 00037 if((*kter) == dhex_conn[i]){ 00038 // push the bulk mesh 00039 dhex_conn[i] = new_vert[nid]; 00040 } 00041 } 00042 MBERRCHK(mb->set_connectivity(*fmter, &dhex_conn[0], dhex_conn.size()), mb); 00043 } 00044 double jac = 0; 00045 vw.quality_measure(*fmter, MB_JACOBIAN, jac); 00046 ++m_JacCalls; 00047 if (jac < 0){ 00048 m_LogFile << "ck BL thickness/intervals. Stopping." << std::endl; 00049 exit(0); 00050 } 00051 } 00052 } 00053 else if(all_bl[count] > 0 && fixmat != -1){ 00054 // node belongs to more than one material and fixmat specified 00055 int nid = (count+1)*m_Intervals - 1; 00056 MBERRCHK(mb->get_coords(&new_vert[nid], 1, coords_new_quad),mb); 00057 MBERRCHK(mb->get_coords(&(*kter), 1, coords_old_quad),mb); 00058 00059 if (debug) { 00060 m_LogFile << std::setprecision (3) << std::scientific << " : NID: " << (nid) 00061 << coords_old_quad[0] 00062 << ", " << coords_old_quad[1] << ", " << coords_old_quad[2] << " OLD:- coords: NEW" << coords_new_quad[0] 00063 << ", " << coords_new_quad[1] << ", " << coords_new_quad[2] << std::endl; 00064 } 00065 00066 // now find the hex in fixmat_ents that was affected by this swap and UNswap the coords 00067 moab::Range fhex; 00068 MBERRCHK(mb->get_adjacencies(&(*kter), 1, m_GD, false, fhex, Interface::UNION), mb); 00069 moab::Range fmhex= intersect(fhex,fixmat_ents); 00070 moab::Range non_fixhex = subtract(fhex, fmhex); 00071 00072 std::vector<int> tag_non_fixhex(non_fixhex.size(),0); 00073 MBERRCHK(mb->tag_get_data(MatIDTag, non_fixhex, &tag_non_fixhex[0]), mb); 00074 m_LogFile << quads.size() << std::endl; 00075 00076 if( matindx < (int) quads.size() ){ 00077 ++matindx; 00078 // handling more than 2 materials in MM case is not supported 00079 blmaterial_id[matindx] = tag_non_fixhex[0]; 00080 } 00081 std::vector<moab::EntityHandle> fmconn; 00082 for(Range::iterator fmter = non_fixhex.begin(); fmter != non_fixhex.end(); ++fmter){ 00083 mb->get_connectivity(&(*fmter), 1, fmconn); 00084 if(fmconn.size () > 0){ 00085 for(int i=0; i < (int)fmconn.size(); i++){ 00086 if((*kter) == fmconn[i]){ 00087 // push the bulk mesh 00088 fmconn[i] = new_vert[nid]; 00089 } 00090 } 00091 MBERRCHK(mb->set_connectivity(*fmter, &fmconn[0], fmconn.size()), mb); 00092 } 00093 double jac = 0; 00094 vw.quality_measure(*fmter, MB_JACOBIAN, jac); 00095 ++m_JacCalls; 00096 if (jac < 0){ 00097 m_LogFile << "ck BL thickness/intervals. Stopping." << std::endl; 00098 exit(0); 00099 } 00100 } 00101 m_LogFile << "Multiple material case: working along the edge" << std::endl; 00102 } 00103 else if(all_bl[count] > 0 && fixmat == -1){ // node belongs to more than one material and fixmat not specified 00104 // NODE ON BOUNDARY 00105 int nid = (count+1)*m_Intervals - 1; 00106 MBERRCHK(mb->get_coords(&new_vert[nid], 1, coords_new_quad),mb); 00107 MBERRCHK(mb->get_coords(&(*kter), 1, coords_old_quad),mb); 00108 MBERRCHK(mb->set_coords(&(*kter), 1, coords_new_quad),mb); 00109 MBERRCHK(mb->set_coords(&new_vert[nid], 1, coords_old_quad),mb); 00110 00111 m_LogFile << std::setprecision (3) << std::scientific << " : NID:" << (nid) 00112 << coords_old_quad[0] 00113 << ", " << coords_old_quad[1] << ", " << coords_old_quad[2] << " OLD:- coords: NEW" << coords_new_quad[0] 00114 << ", " << coords_new_quad[1] << ", " << coords_new_quad[2] << std::endl; 00115 } 00116 } // for loop ends 00117 00118 if(debug == true){ 00119 MBERRCHK(mb->write_mesh("bulkpushed.exo"),mb); 00120 m_LogFile << "\n\nWrote Mesh File: bulkpushed.exo" << std::endl; 00121 } 00122 // check for the volume of penultimate elements if -ve volume encountered. Report. 00123 count = -1; 00124 // Try to move another layer attached to it. 00125 for (Range::iterator kter = nodes.begin(); kter != nodes.end(); ++kter){ 00126 ++count; 00127 for(int j=0; j< m_Intervals; j++){ 00128 int nid = count*m_Intervals+j; 00129 double coords_new_quad[3]; 00130 MBERRCHK(mb->get_coords(&new_vert[nid], 1, coords_new_quad),mb); 00131 m_LogFile << std::setprecision (3) << std::scientific << " : NID:" << (nid) 00132 << " of " << new_vert.size() << " new nodes:- coords: " << coords_new_quad[0] 00133 << ", " << coords_new_quad[1] << ", " << coords_new_quad[2] << std::endl; 00134 } 00135 } 00136 // shoot multiple normals for multiple materials case only. 00137 // This can be used of regular case also how to invoke it. mention in algorithm 00138 // mention local and global smoothing. 00139 // qcount = -1; 00140 // int flag[quads.size()]; 00141 return 0; 00142 } 00143 }