Skip to content
Snippets Groups Projects
Commit b29c7f4e authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Write first-order configurations using the new VTKFile class instead of GeometryGrid

[[Imported from SVN: r9894]]
parent 36656a83
No related branches found
No related tags found
No related merge requests found
...@@ -304,55 +304,77 @@ public: ...@@ -304,55 +304,77 @@ public:
vtkFile.write(filename); vtkFile.write(filename);
#else // FIRST_ORDER #else // FIRST_ORDER
typedef typename GridType::LeafGridView GridView;
const GridType& grid = basis.getGridView().grid(); Dune::GFE::VTKFile vtkFile(gridView.comm().rank(), gridView.comm().size());
////////////////////////////////////////////////////////////////////////////////// // Stupid: I can't directly get the number of Interior_Partition elements
// Deform the grid according to the position information in 'configuration' size_t numElements = 0;
////////////////////////////////////////////////////////////////////////////////// for (auto it = gridView.template begin<0,Dune::Interior_Partition>(); it != gridView.template end<0,Dune::Interior_Partition>(); ++it)
numElements++;
typedef Dune::GeometryGrid<GridType,DeformationFunction<GridView> > DeformedGridType; // Enter vertex coordinates
std::vector<Dune::FieldVector<double, 3> > points(configuration.size());
for (size_t i=0; i<configuration.size(); i++)
points[i] = configuration[i].r;
DeformationFunction<typename GridType::LeafGridView> deformationFunction(grid.leafGridView(), configuration); vtkFile.points_ = points;
// stupid, can't instantiate deformedGrid with a const grid // Enter elements
DeformedGridType deformedGrid(const_cast<GridType&>(grid), deformationFunction); std::vector<int> connectivity(numElements*4);
typedef P1NodalBasis<typename DeformedGridType::LeafGridView,double> DeformedP1Basis; size_t i=0;
DeformedP1Basis deformedP1Basis(deformedGrid.leafGridView()); for (auto it = gridView.template begin<0,Dune::Interior_Partition>(); it != gridView.template end<0,Dune::Interior_Partition>(); ++it)
{
if (it->type().isQuadrilateral())
{
connectivity[i++] = basis.index(*it,0);
connectivity[i++] = basis.index(*it,1);
connectivity[i++] = basis.index(*it,3);
connectivity[i++] = basis.index(*it,2);
}
}
Dune::VTKWriter<typename DeformedGridType::LeafGridView> vtkWriter(deformedGrid.leafGridView()); vtkFile.cellConnectivity_ = connectivity;
// Make three vector fields containing the directors std::vector<int> offsets(numElements);
typedef std::vector<Dune::FieldVector<double,3> > CoefficientType; i = 0;
int offsetCounter = 0;
for (auto it = gridView.template begin<0>(); it != gridView.template end<0>(); ++it)
{
if (it->type().isQuadrilateral())
offsetCounter += 4;
offsets[i++] += offsetCounter;
}
std::vector<CoefficientType> directors(3); vtkFile.cellOffsets_ = offsets;
for (int i=0; i<3; i++) { std::vector<int> cellTypes(numElements);
i = 0;
for (auto it = gridView.template begin<0>(); it != gridView.template end<0>(); ++it)
{
if (it->type().isQuadrilateral())
cellTypes[i++] = 9;
}
vtkFile.cellTypes_ = cellTypes;
directors[i].resize(configuration.size()); // Z coordinate for better visualization of wrinkles
for (size_t j=0; j<configuration.size(); j++) std::vector<double> zCoord(points.size());
directors[i][j] = configuration[j].q.director(i); for (size_t i=0; i<configuration.size(); i++)
zCoord[i] = configuration[i].r[2];
std::stringstream iAsAscii; vtkFile.zCoord_ = zCoord;
iAsAscii << i;
Dune::shared_ptr<VTKBasisGridFunction<DeformedP1Basis,CoefficientType> > vtkDirector // The three director fields
= Dune::make_shared<VTKBasisGridFunction<DeformedP1Basis,CoefficientType> > for (size_t i=0; i<3; i++)
(deformedP1Basis, directors[i], "director"+iAsAscii.str()); {
vtkWriter.addVertexData(vtkDirector); vtkFile.directors_[i].resize(configuration.size());
for (size_t j=0; j<configuration.size(); j++)
vtkFile.directors_[i][j] = configuration[j].q.director(i);
} }
// For easier visualization of wrinkles: add z-coordinate as scalar field // Actually write the VTK file to disk
std::vector<double> zCoord(configuration.size()); vtkFile.write(filename);
for (size_t i=0; i<zCoord.size(); i++)
zCoord[i] = configuration[i].r[2];
vtkWriter.addVertexData(zCoord, "zCoord");
// Write the file to disk
vtkWriter.write(filename);
#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