Hi, this could well be impossible to answer with the information I have but just wanted to check. I have to create a mesh to be read by another program, the mesh is the placement of particles for certain spacings, and my output can't be read by the the program created by another person. I have no access to the code of this program so cannot check how it works the only thing I have is an example mesh:
#include <iostream>
#include <iomanip>
#include <fstream>
usingnamespace std;
int main()
{
double c1x;
double c2x;
double c3x;
double c1y;
double c2y;
double c3y;
double how;
double vol;
double xv;
double yv;
double spacing;
double cx;
double cy;
double nop;
int n=1;
ofstream outFile;
outFile.open("mesh.mes");
cout<<"Please enter x-value for co-ordinate 1:"<<endl;
cin>>c1x;
cout<<endl<<"Please enter y-value for co-ordinate 1:"<<endl;
cin>>c1y;
cout<<endl<<"Please enter x-value for co-ordinate 2:"<<endl;
cin>>c2x;
cout<<endl<<"Please enter y-value for co-ordinate 2:"<<endl;
cin>>c2y;
cout<<endl<<"Please enter x-value for co-ordinate 3:"<<endl;
cin>>c3x;
cout<<endl<<"Please enter y-value for co-ordinate 3:"<<endl;
cin>>c3y;
cout<<endl<<"Please enter height of water above bottom co-ordinate:"<<endl;
cin>>how;
cout<<endl<<"Please enter the spacing:"<<endl;
cin>>spacing;
cout<<endl<<"Please enter the particle volum:"<<endl;
cin>>vol;
cout<<endl<<"Please enter the x-velocity:"<<endl;
cin>>xv;
cout<<endl<<"Please enter the y-velocity:"<<endl;
cin>>yv;
if(c1y == c2y && c2x == c3x)
{
cx=c1x;
cy=c1y;
nop=(((c2x-c1x)/spacing)+1)*(((how)/spacing)+1);
outFile<<"total no. of points:"<<" "<<nop<<"\n";
while(cx<=c2x)
{
while(cy<=(how+c1y))
{
outFile<<" "<<n<<" "<<cx<<" "<<cy<<" "<<"\n";
cy=cy+spacing;
n++;
}
outFile<<" "<<n<<" "<<cx<<" "<<cy<<" "<<"\n";
n++;
cx=cx+spacing;
cy=c1y;
}
n=1;
outFile<<"initial condition (x-velocity y-velocity volume)"<<"\n";
while(n<=(nop))
{
outFile<<" "<<n<<" "<<xv<<" "<<yv<<" "<<vol<<"\n";
n++;
}
}
outFile.close();
return 0;
}
I've tried it without the tabs between the file outputs as well with no joy. So in a nutshell how do I put my outputs into the same form as the table above? Any help is greatly appreaciated!
Haha, didn't know about "\t"! Well I won't be making that mistake again. It has been sorted now, turns out that the problem was in the first line of the output as it wants two spaces between the text and the number for whatever reason.