Skip to content
Snippets Groups Projects
Commit 370770ae authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

added method to write scalar element data, removed old data writing method for line set rods

[[Imported from SVN: r2304]]
parent 3f4037c8
No related branches found
No related tags found
No related merge requests found
...@@ -148,21 +148,9 @@ void writeRod(const std::vector<Configuration>& rod, ...@@ -148,21 +148,9 @@ void writeRod(const std::vector<Configuration>& rod,
/** \brief Write a spatial rod along with a strain or stress field /** \brief Write a spatial rod along with a strain or stress field
*/ */
template <int ndata> void writeRodElementData(Dune::BlockVector<Dune::FieldVector<double, 1> >& data,
void writeRod(const std::vector<Configuration>& rod, Dune::BlockVector<Dune::FieldVector<double, ndata> >& data, const std::string& filename)
const std::string& filename)
{ {
if (data.size() != rod.size()-1)
DUNE_THROW(Dune::Exception, "Size of data vector doesn't match number of vertices");
// #lines in center axis + #lines in set of directors
int nLines = 3*(rod.size()-1) + 3*3*rod.size();
// Don't ever share vertices. That way we can simulate per-element data
int nPoints = nLines/3*2;
double directorLength = 1/((double)rod.size());
// ///////////////////// // /////////////////////
// Write header // Write header
// ///////////////////// // /////////////////////
...@@ -174,84 +162,50 @@ void writeRod(const std::vector<Configuration>& rod, Dune::BlockVector<Dune::Fie ...@@ -174,84 +162,50 @@ void writeRod(const std::vector<Configuration>& rod, Dune::BlockVector<Dune::Fie
outfile << "# CreationDate: Mon Jul 18 17:14:27 2005" << std::endl; outfile << "# CreationDate: Mon Jul 18 17:14:27 2005" << std::endl;
outfile << std::endl; outfile << std::endl;
outfile << std::endl; outfile << std::endl;
outfile << "define Lines " << nLines << std::endl; outfile << "define Segments " << data.size() << std::endl;
outfile << "nVertices " << nPoints << std::endl;
outfile << std::endl; outfile << std::endl;
outfile << "Parameters {" << std::endl; outfile << "Parameters {" << std::endl;
outfile << " ContentType \"HxLineSet\"" << std::endl; outfile << " ContentType \"ScalarRodField\"" << std::endl;
outfile << " Encoding \"OnSegments\"" << std::endl;
outfile << "}" << std::endl; outfile << "}" << std::endl;
outfile << std::endl; outfile << std::endl;
outfile << "Lines { int LineIdx } @1" << std::endl; outfile << "Segments { float Data } @1" << std::endl;
outfile << "Vertices { float[3] Coordinates } @2" << std::endl;
for (int i=0; i<ndata; i++)
outfile << "Vertices {float Data" << i << " } @" << 3+i << std::endl;
outfile << std::endl; outfile << std::endl;
outfile << "# Data section follows" << std::endl; outfile << "# Data section follows" << std::endl;
outfile << "@1" << std::endl; outfile << "@1" << std::endl;
// /////////////////////////////////////// // ///////////////////////////////////////
// write lines // write data
// ///////////////////////////////////////
for (int i=0; i<nLines/3; i++)
outfile << 2*i << std::endl << 2*i+1 << std::endl << "-1" << std::endl;
// ///////////////////////////////////////
// Write the vertices
// /////////////////////////////////////// // ///////////////////////////////////////
outfile << std::endl << "@2" << std::endl; for (int i=0; i<data.size(); i++)
outfile << data[i] << std::endl;
// The center axis
for (int i=0; i<rod.size()-1; i++) {
outfile << rod[i].r[0] << " " << rod[i].r[1] << " " << rod[i].r[2] << std::endl;
outfile << rod[i+1].r[0] << " " << rod[i+1].r[1] << " " << rod[i+1].r[2] << std::endl;
}
// The directors
for (int i=0; i<rod.size(); i++) {
Dune::FieldVector<double, 3> director[3];
director[0] = rod[i].q.director(0);
director[1] = rod[i].q.director(1);
director[2] = rod[i].q.director(2);
director[0] *= directorLength; std::cout << "Result written successfully to: " << filename << std::endl;
director[1] *= directorLength;
director[2] *= directorLength;
outfile << rod[i].r[0] << " " << rod[i].r[1] << " " << rod[i].r[2] << std::endl; }
outfile << rod[i].r[0]+director[0][0] << " " << rod[i].r[1]+director[0][1] << " " << rod[i].r[2]+director[0][2] << std::endl;
outfile << rod[i].r[0] << " " << rod[i].r[1] << " " << rod[i].r[2] << std::endl;
outfile << rod[i].r[0]+director[1][0] << " " << rod[i].r[1]+director[1][1] << " " << rod[i].r[2]+director[1][2] << std::endl;
outfile << rod[i].r[0] << " " << rod[i].r[1] << " " << rod[i].r[2] << std::endl;
outfile << rod[i].r[0]+director[2][0] << " " << rod[i].r[1]+director[2][1] << " " << rod[i].r[2]+director[2][2] << std::endl;
} void writeRodStress(Dune::BlockVector<Dune::FieldVector<double, 6> >& data,
const std::string& basename)
{
Dune::BlockVector<Dune::FieldVector<double, 1> > scalarStress(data.size());
outfile << std::endl; // Extract separate stress values and write them
for (int i=0; i<6; i++) {
// /////////////////////////////////////// for (size_t j=0; j<data.size(); j++)
// Write data scalarStress[j] = data[j][i];
// ///////////////////////////////////////
for (int i=0; i<ndata; i++) {
outfile << "@" << 3+i << std::endl; // create a name
std::stringstream iAsAscii;
for (int j=0; j<nPoints/2; j++) { iAsAscii << i;
double value = (j<data.size()) ? data[j][i] : 0;
outfile << value << std::endl << value << std::endl;
}
outfile << std::endl; // write the scalar field
writeRodElementData(scalarStress, basename + ".stress" + iAsAscii.str());
} }
std::cout << "Result written successfully to: " << filename << std::endl;
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment