void WitnessSet::receive(int source, ParallelismConfig & mpi_config) { MPI_Status statty_mc_gatty; int *buffer = new int[8]; MPI_Recv(buffer, 8, MPI_INT, WITNESS_SET, source, mpi_config.comm(), &statty_mc_gatty); set_dimension(buffer[0]); comp_num_ = buffer[1]; incid_num_ = buffer[2]; num_vars_ = buffer[3]; num_natty_vars_ = buffer[4]; unsigned int temp_num_pts = buffer[5]; unsigned int temp_num_linears = buffer[6]; unsigned int temp_num_patches = buffer[7]; delete [] buffer; vec_mp tempvec; init_vec_mp2(tempvec,0,1024); for (unsigned int ii=0; ii<temp_num_linears; ii++) { receive_vec_mp(tempvec,source); add_linear(tempvec); } for (unsigned int ii=0; ii<temp_num_patches; ii++) { receive_vec_mp(tempvec,source); add_patch(tempvec); } for (unsigned int ii=0; ii<temp_num_pts; ii++) { receive_vec_mp(tempvec,source); add_point(tempvec); } clear_vec_mp(tempvec); return; }
/** \brief copy all the patches from another PatchHolder Copy all the stored mp patches from another PatchHolder object, without testing for uniqueness. \param other the PatchHolder from which to copy. */ void copy_patches(const PatchHolder & other) { for (unsigned int ii=0; ii<other.num_patches_; ii++) add_patch(other.patch_mp_[ii]); }
void CHARMMParameters::read_topology_file(base::TextInput input_file, bool translate_names_to_pdb) { IMP_OBJECT_LOG; const String MASS_LINE = "MASS"; const String DEFA_LINE = "DEFA"; const String PATC_LINE = "PATC"; const String RESI_LINE = "RESI"; const String PRES_LINE = "PRES"; const String ATOM_LINE = "ATOM"; const String DELE_LINE = "DELE"; const String BOND_LINE = "BOND"; const String BOND_LINE2 = "DOUBLE"; const String ANGLE_LINE = "ANGL"; const String ANGLE_LINE2 = "THET"; const String DIHEDRAL_LINE = "DIHE"; const String DIHEDRAL_LINE2 = "PHI"; const String IMPROPER_LINE = "IMPR"; const String IMPROPER_LINE2 = "IMPH"; const String IC_LINE = "IC"; std::string first_patch = "", last_patch = ""; Pointer<CHARMMIdealResidueTopology> residue; Pointer<CHARMMPatch> patch; ResidueType curr_res_type; while (!input_file.get_stream().eof()) { String line; getline(input_file.get_stream(), line); boost::trim(line); // remove all spaces // skip comments or empty lines if (line[0] == '!' || line[0] == '*' || line.length() == 0) continue; // read residue line if(line.substr(0, RESI_LINE.length()) == RESI_LINE) { if (residue) { add_residue_topology(residue.release()); } else if (patch) { add_patch(patch.release()); } curr_res_type = parse_residue_line(line, translate_names_to_pdb); ResidueType rt(curr_res_type.get_string()); residue = new CHARMMIdealResidueTopology(rt); residue->set_default_first_patch(first_patch); residue->set_default_last_patch(last_patch); // handle patch residues } else if (line.substr(0, PRES_LINE.length()) == PRES_LINE) { if (residue) { add_residue_topology(residue.release()); } else if (patch) { add_patch(patch.release()); } Strings split_results; boost::split(split_results, line, boost::is_any_of(" \t"), boost::token_compress_on); if (split_results.size() < 3) { IMP_THROW("Invalid PRES line: " << line, ValueException); } patch = new CHARMMPatch(get_residue_name(split_results[1], translate_names_to_pdb)); // handle MASS line } else if (line.substr(0, MASS_LINE.length()) == MASS_LINE) { parse_mass_line(line, atom_type_to_element_); // handle DEFA line } else if (line.substr(0, DEFA_LINE.length()) == DEFA_LINE) { parse_patch_line(line, first_patch, last_patch, translate_names_to_pdb); // handle PATC line } else if (line.substr(0, PATC_LINE.length()) == PATC_LINE && residue) { std::string first = residue->get_default_first_patch(); std::string last = residue->get_default_last_patch(); parse_patch_line(line, first, last, translate_names_to_pdb); residue->set_default_first_patch(first); residue->set_default_last_patch(last); // read DELE line } else if (line.substr(0, DELE_LINE.length()) == DELE_LINE && patch) { parse_dele_line(line, patch, translate_names_to_pdb); // read atom line } else if (line.substr(0, ATOM_LINE.length()) == ATOM_LINE && (residue || patch)) { parse_atom_line(line, curr_res_type, get_residue(residue, patch), translate_names_to_pdb); // read bond line } else if ((line.substr(0, BOND_LINE.length()) == BOND_LINE || line.substr(0, BOND_LINE2.length()) == BOND_LINE2) && (residue || patch)) { parse_bond_line(line, curr_res_type, get_residue(residue, patch), translate_names_to_pdb); // read angle line } else if ((line.substr(0, ANGLE_LINE.length()) == ANGLE_LINE || line.substr(0, ANGLE_LINE2.length()) == ANGLE_LINE2) && (residue || patch)) { parse_angle_line(line, get_residue(residue, patch), translate_names_to_pdb); // read dihedral line } else if ((line.substr(0, DIHEDRAL_LINE.length()) == DIHEDRAL_LINE || line.substr(0, DIHEDRAL_LINE2.length()) == DIHEDRAL_LINE2) && (residue || patch)) { parse_dihedral_line(line, get_residue(residue, patch), translate_names_to_pdb); // read improper line } else if ((line.substr(0, IMPROPER_LINE.length()) == IMPROPER_LINE || line.substr(0, IMPROPER_LINE2.length()) == IMPROPER_LINE2) && (residue || patch)) { parse_improper_line(line, get_residue(residue, patch), translate_names_to_pdb); // read internal coordinate line } else if (line.substr(0, IC_LINE.length()) == IC_LINE && (residue || patch)) { parse_internal_coordinate_line(line, get_residue(residue, patch), translate_names_to_pdb); } } if (residue) { add_residue_topology(residue); } else if (patch) { add_patch(patch); } }
int main(int argc, char *argv[]){ MPI_Init(&argc, &argv); MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &shmcomm); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); double t_begin; int i, j, k, ii, id, id1; t_begin = MPI_Wtime(); // record the begining CPU time read_param(); lattice_vec(); allocate(); p_allocate(); if (flow_on!=0) { build_stream(); } if (Q_on!=0) { build_neighbor(); } init_surf(); add_patch(); p_init(); p_iden(); init(); if (flow_on!=0) cal_fequ(f); if (Q_on!=0) cal_dQ(); if (Q_on!=0 && flow_on!=0 && newrun_on!=0) { while(qconverge==0) { t_current++; for (ii=0; ii<n_evol_Q; ii++) { cal_dQ(); evol_Q(); } if (t_current%t_print==0) monitor(); } e_tot =-1; k_eng =-1; qconverge = 0; uconverge = 0; t_current =-1; } if (Q_on!=0 && flow_on!=0) { cal_W(); cal_stress(); cal_sigma_p(); } MPI_Barrier(MPI_COMM_WORLD); output1(1,'z',Nx/2,Ny/2); output3(1); if(myid==0) printf("Q initialized\n"); MPI_Barrier(MPI_COMM_WORLD); while (t_current<t_max && uconverge*qconverge==0) { e_toto=e_tot; if (Q_on!=0 && qconverge==0) { if (flow_on!=0 && uconverge==0) cal_W(); for (ii=0; ii<n_evol_Q; ii++) { cal_dQ(); evol_Q(); } } if (flow_on!=0 && uconverge==0) { if (Q_on!=0 && qconverge==0) { cal_stress(); cal_sigma_p(); } evol_f(f,f2); } if (Q_on!=0 && qconverge==0) { if (flow_on!=0 && uconverge==0) cal_W(); for (ii=0; ii<n_evol_Q; ii++) { cal_dQ(); evol_Q(); } } if (flow_on!=0 && uconverge==0) { if (Q_on!=0 && qconverge==0) { cal_stress(); cal_sigma_p(); } evol_f(f2,f); } if (t_current%t_print==0) monitor(); if (t_current%t_write==0) { output1(0,'z',Nx/2,Ny/2); output3(0); fflush(stdout); } t_current++; } output_time(t_begin); output1(0,'z',Nx/2,Ny/2); output3(0); write_restart(); p_deallocate(); deallocate(); return 0; }
int WitnessSet::Parse(const boost::filesystem::path witness_set_file, const int num_vars) { FILE *IN = safe_fopen_read(witness_set_file); int temp_num_patches, patch_size, temp_num_linears, temp_num_points, num_vars_in_linears; fscanf(IN, "%d %d %d", &temp_num_points, &dim_, &comp_num_); scanRestOfLine(IN); this->num_vars_ = num_vars; this->num_natty_vars_ = num_vars; vec_mp temp_vec; init_vec_mp2(temp_vec, num_vars,1024); temp_vec->size = num_vars; for (int ii=0; ii < temp_num_points; ii++) { //read the witness points into memory for (int jj=0; jj < num_vars; ++jj) { mpf_inp_str(temp_vec->coord[jj].r, IN, 10); // 10 is the base mpf_inp_str(temp_vec->coord[jj].i, IN, 10); scanRestOfLine(IN); } add_point(temp_vec); } fscanf(IN, "%d %d", &temp_num_linears, &num_vars_in_linears); scanRestOfLine(IN); for (int ii=0; ii < temp_num_linears; ii++) { change_size_vec_mp(temp_vec,num_vars_in_linears); temp_vec->size = num_vars_in_linears; //read the witness linears into memory for (int jj=0; jj < num_vars_in_linears; jj++) { mpf_inp_str(temp_vec->coord[jj].r, IN, 10); mpf_inp_str(temp_vec->coord[jj].i, IN, 10); scanRestOfLine(IN); } add_linear(temp_vec); } fscanf(IN, "%d %d", &temp_num_patches, &patch_size); scanRestOfLine(IN); if (temp_num_patches>1) { std::cerr << temp_num_patches << " patches detected. this probably indicates a problem." << std::endl; std::cerr << "the file being read: " << witness_set_file << std::endl; std::cerr << "trying to read " << num_vars << " variables." << std::endl; mypause(); } for (int ii=0; ii < temp_num_patches; ii++) { change_size_vec_mp(temp_vec,patch_size); temp_vec->size = patch_size; //read the patch into memory for (int jj=0; jj < patch_size; jj++) { mpf_inp_str(temp_vec->coord[jj].r, IN, 10); mpf_inp_str(temp_vec->coord[jj].i, IN, 10); scanRestOfLine(IN); } add_patch(temp_vec); } fclose(IN); clear_vec_mp(temp_vec); return 0; }