void Mesh::optimize() { std::vector<int> fixed(this->_n_nodes); std::fill(fixed.begin(),fixed.end(), 0); for(int s = 0; s < this->_bnd_nodes.surfaces.size(); s++ ) { std::vector<int> *surface = &this->_bnd_nodes.surfaces[s]; for(std::vector<int>::iterator iter = surface->begin(); iter != surface->end(); iter++) { int node_id = *iter; fixed[node_id] = 1; } } int dim = 3; unsigned long int nnodes = get_n_nodes(); unsigned long int nelem = get_n_elements(); unsigned long *conn = &this->_elements[0]; double *coords = &this->_xyz[0]; int *fptr = &fixed[0]; Mesquite::ArrayMesh mesq_mesh(dim, nnodes, coords, fptr, nelem, Mesquite::TETRAHEDRON, conn); Mesquite::MsqError error; Mesquite::LaplacianSmoother lapl1; Mesquite::InstructionQueue q1; Mesquite::ConditionNumberQualityMetric shape_metric; Mesquite::EdgeLengthQualityMetric lapl_met; lapl_met.set_averaging_method(Mesquite::QualityMetric::RMS); Mesquite::QualityAssessor stop_qa = Mesquite::QualityAssessor(&shape_metric); stop_qa.add_quality_assessment(&lapl_met); Mesquite::TerminationCriterion sc2; sc2.add_iteration_limit(10); lapl1.set_outer_termination_criterion(&sc2); q1.add_quality_assessor(&stop_qa, error); q1.set_master_quality_improver(&lapl1, error); q1.add_quality_assessor(&stop_qa, error); q1.run_instructions(&mesq_mesh, error); //shape_wrapper.run_instructions(&mesq_mesh,error); //optmizer.run_instructions(&mesq_mesh,error); if (error) { std::cout << " Error smoothing mesh: " << std::endl << error << std::endl; } }
/*---------------------------------------------------------------------------*/ int check_reachable_count() { int i; int count = 0; for(i=0; i<get_n_nodes(); i++) { uip_ipaddr_t dest_ipaddr; uint8_t id = get_node_id(i); if(id == ROOT_ID) { continue; } node_ip6addr(&dest_ipaddr, id); if(is_in_subdodag(&dest_ipaddr)) { count++; } } printf("App: nodes reachable: %u/%u\n", count, get_n_nodes()-1 /* exclude sink */); return count >= ((get_n_nodes()-1) * (TARGET_REACHABLE_RATIO)) / 100; }
/*---------------------------------------------------------------------------*/ int check_reachable_count() { int i; int count = 0; for(i=0; i<get_n_nodes(); i++) { uip_ipaddr_t dest_ipaddr; uint8_t id = get_node_id_from_index(i); if(id == ROOT_ID) { continue; } set_ipaddr_from_id(&dest_ipaddr, id); if(orpl_routing_set_contains(&dest_ipaddr)) { count++; } } if(count != get_n_nodes()-1) { printf("App: nodes reachable: %u/%u\n", count, get_n_nodes()-1 /* exclude sink */); } return count >= ((get_n_nodes()-1) * (TARGET_REACHABLE_RATIO)) / 100; }