void writePDB(double* geomData, char* fileName_PDB) {
	const char* inpFile = "writePDB.inp";
	const char* mainoutFile = "main_out.MetPDB";
	const char* logFile  = "log";
	const char* errorFile = "err";


	// write the configuration file used for ECEPP/3 model engine
	ofstream outFile(inpFile, ios::out);
	outFile << "$CNTRL" << endl;
	outFile << "runtyp = energy" << endl;
	outFile << "PRINT_CART" << endl;
	outFile << "OUTFORMAT = PDB" << endl;
	outFile << "FILE = ";  
	outFile << fileName_PDB << endl;
	outFile << "res_code= one_letter" << endl;

	outFile << "$END" << endl << endl;

	outFile << "$SEQ" << endl;
	outFile << "H" << endl;
	outFile << "YGGFM" << endl;
	outFile << "O" << endl;
	outFile << "$END" << endl;


	outFile << "$GEOM" << endl << endl;
	for(int i=0; i<6;i++) {
		outFile	<< setw(8) // 设定field宽度
				<< setprecision(3) // 设置小数位置
				<< setiosflags(ios::showpoint) // keep trailing 0s
				<< setiosflags(ios::fixed) // 使用这些设置
				<< geomData[i];
	}
	outFile << endl;

	for(i=6; i<9;i++) {
		outFile	<< setw(8) // 设定field宽度
				<< setprecision(3) // 设置小数位置
				<< setiosflags(ios::showpoint) // keep trailing 0s
				<< setiosflags(ios::fixed) // 使用这些设置
				<< geomData[i];
	}
	outFile << endl;

	for(i=9; i<12;i++) {
		outFile	<< setw(8) // 设定field宽度
				<< setprecision(3) // 设置小数位置
				<< setiosflags(ios::showpoint) // keep trailing 0s
				<< setiosflags(ios::fixed) // 使用这些设置
				<< geomData[i];
	}
	outFile << endl;

	for(i=12; i<17;i++) {
		outFile	<< setw(8) // 设定field宽度
				<< setprecision(3) // 设置小数位置
				<< setiosflags(ios::showpoint) // keep trailing 0s
				<< setiosflags(ios::fixed) // 使用这些设置
				<< geomData[i];
	}
	outFile << endl;

	for(i=17; i<24;i++) {
		outFile	<< setw(8) // 设定field宽度
				<< setprecision(3) // 设置小数位置
				<< setiosflags(ios::showpoint) // keep trailing 0s
				<< setiosflags(ios::fixed) // 使用这些设置
				<< geomData[i];
	}
	outFile << endl;
	outFile << endl;
	outFile << "$END" << endl;

	outFile.flush();
	outFile.close();
	system("i.bat ENERGY writePDB MetPDB x x 1>> log 2> err");

	ofstream outFile1(inpFile, ios::out);
	outFile1.flush();
	outFile1.close();

	ofstream outFile2(mainoutFile, ios::out);
	outFile2.flush();
	outFile2.close();
	
	ofstream outFile3(logFile, ios::out);
	outFile3.flush();
	outFile3.close();

	ofstream outFile4(errorFile, ios::out);
	outFile4.flush();
	outFile4.close();
}
Exemple #2
0
// Initialize method
void 
ConvDiff_PDE::initialize()
{
  // Verify we have only one dependent problem and that it is of the appropriate type
  if( 1 < depProblems.size() )
  {
    std::string msg = "ERROR: ConvDiff_PDE::initialize : Problem \"" + myName
                    + "\" depends on more than one other problem.";
    throw msg;
  }

  GenericEpetraProblem & depProb = myManager->getProblem( depProblems[0] );
  depProbPtr = dynamic_cast<ConvDiff_PDE *>(&depProb);
  if( NULL == depProbPtr )
  {
    std::string msg = "ERROR: ConvDiff_PDE::initialize : Dependent problem \"" 
                    + depProb.getName() + "\" is not of type ConvDiff_PDE.";
    throw msg;
  }

  // Determine relative location of coupling interface
  if( (*xptr)[0] < depProbPtr->getMesh()[0] )
    myInterface = RIGHT;
  else
    myInterface = LEFT;

  // Set exact interface temperature accordingly
  if( LEFT == myInterface )
    T1_exact = Tleft ;
  else
    T1_exact = Tright;

  // Choose appropriate element and nodes for interfacial BC enforcement
  int OverlapNumMyNodes = OverlapMap->NumMyElements(); // this may break in parallel
  if( LEFT == myInterface )
  {
    interface_elem = 0                     ;
    local_node     = 0                     ;
    interface_node = 0                     ;
    opposite_node  = OverlapNumMyNodes - 1 ;
    dirScale       = 1.0                   ;
  }
  else
  {
    interface_elem = OverlapNumMyNodes - 2 ;
    local_node     = 1                     ;
    interface_node = OverlapNumMyNodes - 1 ;
    opposite_node  = 0                     ;
    dirScale       = -1.0                  ;
  }

  // Use this method to compute and output the analytic solution and its first derivative
  exactSolution     = Teuchos::rcp( new Epetra_Vector(*initialSolution) );
  dTdx              = Teuchos::rcp( new Epetra_Vector(*initialSolution) );
  Epetra_Vector & x = *xptr;

  if( 1.e-20 < fabs(peclet) )
  {
    for( int i = 0; i < NumMyNodes; ++i ) 
    {
      (*exactSolution)[i] = (T1_exact - Tleft*exp(peclet) + (Tleft - T1_exact)*exp(peclet*(x[i]-xmin))) /
                            ( 1.0 - exp(peclet) );
      (*dTdx         )[i] = peclet * (Tleft - T1_exact)*exp(peclet*(x[i]-xmin)) /
                            ( 1.0 - exp(peclet) );
    }
  }
  else
  {
    for( int i = 0; i < NumMyNodes; ++i ) 
    {
      (*exactSolution)[i] = (Tright - T1_exact)*(x[i] - xmax) + Tright  ;
      (*dTdx         )[i] =  Tright - T1_exact                          ;
    }
  }

  ostringstream sval; 
  sval << myId << flush; 
  std::string fileName1 = "analytic_" + sval.str(); 
  std::string fileName2 = "dTdx_"     + sval.str(); 

  std::ofstream outFile1(fileName1.c_str());
  std::ofstream outFile2(fileName2.c_str());
  if( !outFile1 || !outFile2 )
  {
    std::string msg = "ERROR: Could not open one of files \"" + fileName1 + "\"" + " or \""
                      + fileName2 + "\"";
    throw msg;
  }

  for( int i = 0; i < NumMyNodes; ++i ) 
  {
    outFile1 << i << "  " << x[i] << "  " << (*exactSolution)[i] << std::endl;
    outFile2 << i << "  " << x[i] << "  " << (*dTdx         )[i] << std::endl;
  }
}