Changeset 12298c for src/boundary.cpp


Ignore:
Timestamp:
Dec 29, 2008, 12:25:04 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
6d4a76
Parents:
02bfde
Message:

Now we also produce Raster3D output files additionally to TecPlot ones ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r02bfde r12298c  
    33
    44#define DEBUG 1
     5#define DoTecplotOutput 0
     6#define DoRaster3DOutput 1
     7#define TecplotSuffix ".dat"
     8#define Raster3DSuffix ".r3d"
    59
    610// ======================================== Points on Boundary =================================
     
    564568}
    565569;
     570
     571/** Creates the objects in a raster3d file (renderable with a header.r3d)
     572 * \param *out output stream for debugging
     573 * \param *tecplot output stream for tecplot data
     574 * \param *Tess Tesselation structure with constructed triangles
     575 * \param *mol molecule structure with atom positions
     576 */
     577void write_raster3d_file(ofstream *out, ofstream *rasterfile, class Tesselation *Tess, class molecule *mol)
     578{
     579  atom *Walker = mol->start;
     580  bond *Binder = mol->first;
     581  int i;
     582  Vector *center = mol->DetermineCenterOfAll(out);
     583  if (rasterfile != NULL) {
     584    //cout << Verbose(1) << "Writing Raster3D file ... ";
     585    *rasterfile << "# Raster3D object description, created by MoleCuilder" << endl;
     586    *rasterfile << "@header.r3d" << endl;
     587    *rasterfile << "# All atoms as spheres" << endl;
     588    while (Walker->next != mol->end) {
     589      Walker = Walker->next;
     590      *rasterfile << "2" << endl << "  "; // 2 is sphere type
     591      for (i=0;i<NDIM;i++)
     592        *rasterfile << Walker->x.x[i]+center->x[i] << " ";
     593      *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
     594    }
     595
     596    *rasterfile << "# All bonds as vertices" << endl;
     597    while (Binder->next != mol->last) {
     598      Binder = Binder->next;
     599      *rasterfile << "3" << endl << "  "; // 2 is round-ended cylinder type
     600      for (i=0;i<NDIM;i++)
     601        *rasterfile << Binder->leftatom->x.x[i]+center->x[i] << " ";
     602      *rasterfile << "\t0.03\t";
     603      for (i=0;i<NDIM;i++)
     604        *rasterfile << Binder->rightatom->x.x[i]+center->x[i] << " ";
     605      *rasterfile << "\t0.03\t0. 0. 1." << endl; // radius 0.05 and blue as colour
     606    }
     607
     608    *rasterfile << "# All tesselation triangles" << endl;
     609    for (TriangleMap::iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
     610      *rasterfile << "1" << endl << "  "; // 1 is triangle type
     611      for (i=0;i<3;i++) { // print each node
     612        for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
     613          *rasterfile << TriangleRunner->second->endpoints[i]->node->x.x[j]+center->x[j] << " ";
     614        *rasterfile << "\t";
     615      }
     616      *rasterfile << "1. 0. 0." << endl;  // red as colour
     617      *rasterfile << "18" << endl << "  0.5 0.5 0.5" << endl; // 18 is transparency type for previous object
     618    }
     619  } else {
     620    cerr << "ERROR: Given rasterfile is " << rasterfile << "." << endl;
     621  }
     622  delete(center);
     623};
    566624
    567625/*
     
    19542012/** This function finds a triangle to a line, adjacent to an existing one.
    19552013 * @param out   output stream for debugging
    1956  * @param tecplot output stream for writing found triangles in TecPlot format
    19572014 * @param mol molecule structure with all atoms and bonds
    19582015 * @param Line current baseline to search from
     
    19612018 * @param N number of found triangles
    19622019 */
    1963 void Tesselation::Find_next_suitable_triangle(ofstream *out, ofstream *tecplot,
     2020void Tesselation::Find_next_suitable_triangle(ofstream *out,
    19642021    molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T,
    1965     const double& RADIUS, int N)
     2022    const double& RADIUS, int N, const char *tempbasename)
    19662023{
    19672024  cout << Verbose(1) << "Begin of Find_next_suitable_triangle\n";
     
    19702027  Vector Chord;
    19712028  ofstream *tempstream = NULL;
    1972   char filename[255];
     2029  char NumberName[255];
    19732030  double tmp;
    19742031  //atom* Walker;
     
    20662123      cout << "Letzter Winkel bei " << TrianglesOnBoundaryCount << " Winkel ist " << Storage[2] << endl;
    20672124
    2068 
    2069   if ((TrianglesOnBoundaryCount % 1) == 0)
    2070     {
    2071     cout << Verbose(1) << "Writing temporary non convex hull to file testEnvelope-" << TriangleFilesWritten << "d.dat.\n";
    2072     sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten);
    2073     tempstream = new ofstream(filename, ios::trunc);
    2074     write_tecplot_file(out, tempstream, this, mol, TriangleFilesWritten++);
    2075     tempstream->close();
    2076     tempstream->flush();
    2077     delete(tempstream);
     2125  if ((TrianglesOnBoundaryCount % 10) == 0) {
     2126    sprintf(NumberName, "-%d", TriangleFilesWritten);
     2127    if (DoTecplotOutput) {
     2128      string NameofTempFile(tempbasename);
     2129      NameofTempFile.append(NumberName);
     2130      NameofTempFile.append(TecplotSuffix);
     2131      cout << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     2132      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
     2133      write_tecplot_file(out, tempstream, this, mol, TriangleFilesWritten);
     2134      tempstream->close();
     2135      tempstream->flush();
     2136      delete(tempstream);
     2137    }
     2138    if (DoRaster3DOutput) {
     2139      string NameofTempFile(tempbasename);
     2140      NameofTempFile.append(NumberName);
     2141      NameofTempFile.append(Raster3DSuffix);
     2142      cout << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     2143      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
     2144      write_raster3d_file(out, tempstream, this, mol);
     2145      tempstream->close();
     2146      tempstream->flush();
     2147      delete(tempstream);
     2148    }
     2149    if (DoTecplotOutput || DoRaster3DOutput)
     2150      TriangleFilesWritten++;
    20782151  }
    20792152
    2080   if (TrianglesOnBoundaryCount >189 and TrianglesOnBoundaryCount < 200 )
    2081     {
    2082       cerr << Verbose(0)
    2083           << "WARNING: Already more than " << TrianglesOnBoundaryCount-1 << "triangles, construction probably has crashed." << endl;
    2084       write_tecplot_file(out, tecplot, this, mol, TriangleFilesWritten);
    2085       cout << Verbose(2) << "This is currently added candidate" << Opt_Candidate << endl;
    2086     }
    2087   // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
     2153      // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
    20882154
    20892155  cout << Verbose(2) << " Optimal candidate is " << *Opt_Candidate << endl;
     
    23092375;
    23102376
    2311 void Find_non_convex_border(ofstream *out, ofstream *tecplot, molecule* mol)
     2377void Find_non_convex_border(ofstream *out, const char *filename, molecule* mol)
    23122378{
    23132379  int N = 0;
     
    23192385  cout << Verbose(0) << "Begin of Find_non_convex_border\n";
    23202386  bool flag = false;  // marks whether we went once through all baselines without finding any without two triangles
    2321 
    23222387  Tess->Find_starting_triangle(mol, RADIUS);
    23232388
     
    23272392      if (baseline->second->TrianglesCount == 1)
    23282393        {
    2329           Tess->Find_next_suitable_triangle(out, tecplot, mol,
     2394          Tess->Find_next_suitable_triangle(out, mol,
    23302395              *(baseline->second),
    2331               *(((baseline->second->triangles.begin()))->second), RADIUS, N); //the line is there, so there is a triangle, but only one.
     2396              *(((baseline->second->triangles.begin()))->second), RADIUS, N, filename); //the line is there, so there is a triangle, but only one.
    23322397          flag = true;
    23332398        }
     
    23462411    }
    23472412  cout << Verbose(1) << "Writing final tecplot file\n";
    2348   write_tecplot_file(out, tecplot, Tess, mol, -1);
     2413  if (DoTecplotOutput) {
     2414    string Name(filename);
     2415    Name.append(TecplotSuffix);
     2416    ofstream tecplot(Name.c_str(), ios::trunc);
     2417    write_tecplot_file(out, &tecplot, Tess, mol, -1);
     2418    tecplot.close();
     2419  }
     2420  if (DoRaster3DOutput) {
     2421    string Name(filename);
     2422    Name.append(Raster3DSuffix);
     2423    ofstream raster(Name.c_str(), ios::trunc);
     2424    write_raster3d_file(out, &raster, Tess, mol);
     2425    raster.close();
     2426  }
    23492427
    23502428  cout << Verbose(0) << "End of Find_non_convex_border\n";
Note: See TracChangeset for help on using the changeset viewer.