void defaultWarningHandler(WarnLevel level, char const *message) { if (level & WARN_DEBUG) { // hit a breakpoint if the debugger is attached breaker(); } if (level & logWarnLevel) { defaultWarningLogger(level, message); } if (level & logWarnLevel) { defaultWarningPrinter(level, message); } }
void loop() { int input = 0; char buffer[80]; if (Serial.available() > 0) { // input = Serial.read(); readline(Serial.read(), buffer, 80); Serial.println(buffer); switch(input) { case ALL_VALUES: Serial.print(direction()); Serial.print(' '); Serial.print(velocity()); Serial.print(' '); Serial.println(servo.read()); // return the angle of the servo (0<servo<180) break; case DIRECTION_MSP: //1 Serial.println(direction()); break; case VELOCITY_MSP: //2 Serial.println(velocity()); break; // case BREAK_MSP: // 3 // Serial.flush(); // Serial.print("Enter the new servo angle: "); // input = Serial.read(); // Serial.println(breaker(input)); // break; default: Serial.print("new servo angle: "); Serial.println(breaker(input)); } } }
bool AAdapt::STKAdapt<SizeField>::adaptMesh(const Epetra_Vector& sol, const Epetra_Vector& ovlp_sol) { *output_stream_ << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; *output_stream_ << "Adapting mesh using AAdapt::STKAdapt method " << std::endl; *output_stream_ << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; Albany::AbstractSTKFieldContainer::IntScalarFieldType* proc_rank_field = genericMeshStruct->getFieldContainer()->getProcRankField(); Albany::AbstractSTKFieldContainer::IntScalarFieldType* refine_field = genericMeshStruct->getFieldContainer()->getRefineField(); // Save the current results and close the exodus file // Create a remeshed output file naming convention by adding the remesh_file_index_ ahead of the period std::ostringstream ss; std::string str = base_exo_filename; ss << "_" << remeshFileIndex << "."; str.replace(str.find('.'), 1, ss.str()); *output_stream_ << "Remeshing: renaming output file to - " << str << std::endl; // Open the new exodus file for results stk_discretization->reNameExodusOutput(str); remeshFileIndex++; // printElementData(); SizeField set_ref_field(*eMesh); eMesh->elementOpLoop(set_ref_field, refine_field); // SetUnrefineField set_unref_field(*eMesh); //eMesh.elementOpLoop(set_ref_field, refine_field); // eMesh->save_as("local_tet_N_5_ElementBased_0_.e"); stk_classic::adapt::ElementRefinePredicate erp(0, refine_field, 0.0); stk_classic::adapt::PredicateBasedElementAdapter<stk_classic::adapt::ElementRefinePredicate> breaker(erp, *eMesh, *refinerPattern, proc_rank_field); breaker.setRemoveOldElements(false); breaker.setAlwaysInitializeNodeRegistry(false); for(int ipass = 0; ipass < 3; ipass++) { eMesh->elementOpLoop(set_ref_field, refine_field); #if 0 std::vector<stk_classic::mesh::Entity*> elems; const std::vector<stk_classic::mesh::Bucket*>& buckets = eMesh->get_bulk_data()->buckets(eMesh->element_rank()); for(std::vector<stk_classic::mesh::Bucket*>::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k) { stk_classic::mesh::Bucket& bucket = **k ; const unsigned num_elements_in_bucket = bucket.size(); for(unsigned i_element = 0; i_element < num_elements_in_bucket; i_element++) { stk_classic::mesh::Entity& element = bucket[i_element]; double* f_data = stk_classic::percept::PerceptMesh::field_data_entity(refine_field, element); std::cout << "Element: " << element.identifier() << "Refine field: " << f_data[0] << std::endl; } } #endif // std::cout << "P[" << eMesh->get_rank() << "] ipass= "******"P[" << eMesh->get_rank() << "] done... ipass= "******"local_tet_N_5_ElementBased_1_ipass_"+Teuchos::toString(ipass)+"_.e"); } breaker.deleteParentElements(); // eMesh->save_as("local_tet_N_5_ElementBased_1_.e"); // Throw away all the Albany data structures and re-build them from the mesh if(adapt_params_->get<bool>("Rebalance", false)) genericMeshStruct->rebalanceAdaptedMesh(adapt_params_, epetra_comm_); stk_discretization->updateMesh(); // printElementData(); return true; }
void text_layout::break_line(std::pair<unsigned, unsigned> && line_limits) { text_line line(line_limits.first, line_limits.second); shape_text(line); double scaled_wrap_width = wrap_width_ * scale_factor_; if (!scaled_wrap_width || line.width() < scaled_wrap_width) { add_line(std::move(line)); return; } if (text_ratio_) { double wrap_at; double string_width = line.width(); double string_height = line.line_height(); for (double i = 1.0; ((wrap_at = string_width/i)/(string_height*i)) > text_ratio_ && (string_width/i) > scaled_wrap_width; i += 1.0) ; scaled_wrap_width = wrap_at; } mapnik::value_unicode_string const& text = itemizer_.text(); line_breaker breaker(text, wrap_char_); double current_line_length = 0; int last_break_position = static_cast<int>(line.first_char()); for (unsigned i=line.first_char(); i < line.last_char(); ++i) { std::map<unsigned, double>::const_iterator width_itr = width_map_.find(i); if (width_itr != width_map_.end()) { current_line_length += width_itr->second; } if (current_line_length <= scaled_wrap_width) continue; int break_position = wrap_before_ ? breaker.preceding(i + 1) : breaker.following(i); if (break_position <= last_break_position || break_position == static_cast<int>(BreakIterator::DONE)) { break_position = breaker.following(i); if (break_position == static_cast<int>(BreakIterator::DONE)) { break_position = line.last_char(); } } if (break_position < static_cast<int>(line.first_char())) { break_position = line.first_char(); } if (break_position > static_cast<int>(line.last_char())) { break_position = line.last_char(); } text_line new_line(adjust_last_break_position(last_break_position, repeat_wrap_char_), break_position); clear_cluster_widths(adjust_last_break_position(last_break_position, repeat_wrap_char_), break_position); shape_text(new_line); add_line(std::move(new_line)); last_break_position = break_position; i = break_position - 1; current_line_length = 0; } if (last_break_position == static_cast<int>(line.first_char())) { add_line(std::move(line)); } else if (last_break_position != static_cast<int>(line.last_char())) { text_line new_line(adjust_last_break_position(last_break_position, repeat_wrap_char_), line.last_char()); clear_cluster_widths(adjust_last_break_position(last_break_position, repeat_wrap_char_), line.last_char()); shape_text(new_line); add_line(std::move(new_line)); } }