Commit 5ada89c6 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

examples cleaned up

parent 7a7c7a21
...@@ -38,7 +38,7 @@ void write_dc (std::string prefix, GridView const& gridView, Fct1 const& fct1, F ...@@ -38,7 +38,7 @@ void write_dc (std::string prefix, GridView const& gridView, Fct1 const& fct1, F
vtkWriter.addPointData(fct2, "q1"); vtkWriter.addPointData(fct2, "q1");
vtkWriter.addCellData(fct2, "q0"); vtkWriter.addCellData(fct2, "q0");
vtkWriter.write(prefix + "_" + std::to_string(GridView::dimension) + "d_ascii.vtu"); vtkWriter.write(prefix + "_" + std::to_string(GridView::dimensionworld) + "d_ascii.vtu");
} }
template <class GridView> template <class GridView>
...@@ -47,10 +47,10 @@ void write (std::string prefix, GridView const& gridView) ...@@ -47,10 +47,10 @@ void write (std::string prefix, GridView const& gridView)
using namespace BasisFactory; using namespace BasisFactory;
auto basis = makeBasis(gridView, lagrange<1>()); auto basis = makeBasis(gridView, lagrange<1>());
FieldVector<double,GridView::dimension> c; FieldVector<double,GridView::dimensionworld> c;
if (GridView::dimension > 0) c[0] = 11.0; if (GridView::dimensionworld > 0) c[0] = 11.0;
if (GridView::dimension > 1) c[1] = 7.0; if (GridView::dimensionworld > 1) c[1] = 7.0;
if (GridView::dimension > 2) c[2] = 3.0; if (GridView::dimensionworld > 2) c[2] = 3.0;
std::vector<double> vec(basis.dimension()); std::vector<double> vec(basis.dimension());
interpolate(basis, vec, [&c](auto const& x) { return c.dot(x); }); interpolate(basis, vec, [&c](auto const& x) { return c.dot(x); });
...@@ -77,8 +77,8 @@ int main(int argc, char** argv) ...@@ -77,8 +77,8 @@ int main(int argc, char** argv)
{ {
using GridType = YaspGrid<dim.value>; using GridType = YaspGrid<dim.value>;
FieldVector<double,dim.value> upperRight; upperRight = 1.0; FieldVector<double,dim.value> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim.value,int>(4); auto numElements = filledArray<dim.value,int>(8);
GridType grid(upperRight, numElements); GridType grid(upperRight, numElements, 0, 0);
write("yasp", grid.leafGridView()); write("yasp", grid.leafGridView());
}); });
} }
...@@ -46,10 +46,10 @@ private: ...@@ -46,10 +46,10 @@ private:
template <class GridView> template <class GridView>
void write (std::string prefix, GridView const& gridView) void write (std::string prefix, GridView const& gridView)
{ {
FieldVector<double,GridView::dimension> c; FieldVector<double,GridView::dimensionworld> c;
if (GridView::dimension > 0) c[0] = 11.0; if (GridView::dimensionworld > 0) c[0] = 11.0;
if (GridView::dimension > 1) c[1] = 7.0; if (GridView::dimensionworld > 1) c[1] = 7.0;
if (GridView::dimension > 2) c[2] = 3.0; if (GridView::dimensionworld > 2) c[2] = 3.0;
auto p1Analytic = makeAnalyticGridViewFunction([&c](auto const& x) { return c.dot(x); }, gridView); auto p1Analytic = makeAnalyticGridViewFunction([&c](auto const& x) { return c.dot(x); }, gridView);
...@@ -66,7 +66,7 @@ int main (int argc, char** argv) ...@@ -66,7 +66,7 @@ int main (int argc, char** argv)
using HostGrid = YaspGrid<2>; using HostGrid = YaspGrid<2>;
FieldVector<double,2> bbox = {2.0*M_PI, 2.0*M_PI}; FieldVector<double,2> bbox = {2.0*M_PI, 2.0*M_PI};
std::array<int,2> num = {4, 12}; std::array<int,2> num = {4, 12};
HostGrid hostGrid{bbox, num}; //, std::bitset<2>{"11"}}; HostGrid hostGrid{bbox, num, 0, 0}; //, std::bitset<2>{"11"}};
// grid build up of mapped coordinates // grid build up of mapped coordinates
double R = 1.0, r = 0.25; double R = 1.0, r = 0.25;
......
...@@ -28,7 +28,7 @@ int main(int argc, char** argv) ...@@ -28,7 +28,7 @@ int main(int argc, char** argv)
using GridType = YaspGrid<dim>; using GridType = YaspGrid<dim>;
FieldVector<double,dim> upperRight; upperRight = 1.0; FieldVector<double,dim> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim,int>(8); auto numElements = filledArray<dim,int>(8);
GridType grid(upperRight,numElements); GridType grid(upperRight,numElements,0,0);
using GridView = typename GridType::LeafGridView; using GridView = typename GridType::LeafGridView;
GridView gridView = grid.leafGridView(); GridView gridView = grid.leafGridView();
......
...@@ -30,10 +30,10 @@ void write (std::string prefix, GridView const& gridView) ...@@ -30,10 +30,10 @@ void write (std::string prefix, GridView const& gridView)
using namespace BasisFactory; using namespace BasisFactory;
auto basis = makeBasis(gridView, lagrange<1>()); auto basis = makeBasis(gridView, lagrange<1>());
FieldVector<double,GridView::dimension> c; FieldVector<double,GridView::dimensionworld> c;
if (GridView::dimension > 0) c[0] = 11.0; if (GridView::dimensionworld > 0) c[0] = 11.0;
if (GridView::dimension > 1) c[1] = 7.0; if (GridView::dimensionworld > 1) c[1] = 7.0;
if (GridView::dimension > 2) c[2] = 3.0; if (GridView::dimensionworld > 2) c[2] = 3.0;
// write analytic function // write analytic function
auto p1Analytic = makeAnalyticGridViewFunction([&c](auto const& x) { return c.dot(x); }, gridView); auto p1Analytic = makeAnalyticGridViewFunction([&c](auto const& x) { return c.dot(x); }, gridView);
...@@ -44,7 +44,7 @@ void write (std::string prefix, GridView const& gridView) ...@@ -44,7 +44,7 @@ void write (std::string prefix, GridView const& gridView)
pvdWriter.addPointData(p1Analytic, "p1"); pvdWriter.addPointData(p1Analytic, "p1");
pvdWriter.addCellData(p1Analytic, "p0"); pvdWriter.addCellData(p1Analytic, "p0");
for (double t = 0.0; t < 10.0; t += 1.0) { for (double t = 0.0; t < 10.0; t += 1.0) {
pvdWriter.write(t, prefix + "_" + std::to_string(GridView::dimension) + "d_ascii.vtu"); pvdWriter.write(t, prefix + "_" + std::to_string(GridView::dimensionworld) + "d_ascii.vtu");
} }
} }
...@@ -58,7 +58,7 @@ int main (int argc, char** argv) ...@@ -58,7 +58,7 @@ int main (int argc, char** argv)
// Test PvdWriter for YaspGrid // Test PvdWriter for YaspGrid
using GridType = YaspGrid<2>; using GridType = YaspGrid<2>;
FieldVector<double,2> upperRight; upperRight = 1.0; FieldVector<double,2> upperRight; upperRight = 1.0;
auto numElements = filledArray<2,int>(4); auto numElements = filledArray<2,int>(8);
GridType grid(upperRight, numElements); GridType grid(upperRight, numElements, 0, 0);
write("yasp", grid.leafGridView()); write("yasp", grid.leafGridView());
} }
\ No newline at end of file
...@@ -36,10 +36,10 @@ using int_ = std::integral_constant<int,dim>; ...@@ -36,10 +36,10 @@ using int_ = std::integral_constant<int,dim>;
template <class GridView> template <class GridView>
void write(std::string prefix, GridView const& gridView) void write(std::string prefix, GridView const& gridView)
{ {
FieldVector<double,GridView::dimension> c; FieldVector<double,GridView::dimensionworld> c;
if (GridView::dimension > 0) c[0] = 11.0; if (GridView::dimensionworld > 0) c[0] = 11.0;
if (GridView::dimension > 1) c[1] = 7.0; if (GridView::dimensionworld > 1) c[1] = 7.0;
if (GridView::dimension > 2) c[2] = 3.0; if (GridView::dimensionworld > 2) c[2] = 3.0;
auto fct2 = makeAnalyticGridViewFunction([&c](auto const& x) -> float { return c.dot(x); }, gridView); auto fct2 = makeAnalyticGridViewFunction([&c](auto const& x) -> float { return c.dot(x); }, gridView);
...@@ -77,7 +77,7 @@ void write_yaspgrid(std::integral_constant<int,dim>) ...@@ -77,7 +77,7 @@ void write_yaspgrid(std::integral_constant<int,dim>)
{ {
using GridType = YaspGrid<dim>; using GridType = YaspGrid<dim>;
FieldVector<double,dim> upperRight; upperRight = 1.0; FieldVector<double,dim> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim,int>(12); auto numElements = filledArray<dim,int>(8);
GridType grid(upperRight,numElements,0,0); GridType grid(upperRight,numElements,0,0);
grid.globalRefine(1); grid.globalRefine(1);
...@@ -90,7 +90,7 @@ void write_spgrid(std::integral_constant<int,dim>) ...@@ -90,7 +90,7 @@ void write_spgrid(std::integral_constant<int,dim>)
#if HAVE_DUNE_SPGRID #if HAVE_DUNE_SPGRID
using GridType = SPGrid<double,dim, SPIsotropicRefinement>; using GridType = SPGrid<double,dim, SPIsotropicRefinement>;
FieldVector<double,dim> upperRight; upperRight = 1.0; FieldVector<double,dim> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim,int>(12); auto numElements = filledArray<dim,int>(8);
GridType grid(SPDomain<double,dim>::unitCube(),numElements); GridType grid(SPDomain<double,dim>::unitCube(),numElements);
// grid.globalRefine(1); // grid.globalRefine(1);
......
...@@ -24,14 +24,14 @@ using namespace Dune::Functions; ...@@ -24,14 +24,14 @@ using namespace Dune::Functions;
template <class GridView> template <class GridView>
void write (std::string prefix, GridView const& gridView) void write (std::string prefix, GridView const& gridView)
{ {
FieldVector<double,GridView::dimension> c{11.0, 7.0, 3.0}; FieldVector<double,GridView::dimensionworld> c{11.0, 7.0, 3.0};
auto p1Analytic = makeAnalyticGridViewFunction([&c](auto const& x) -> float { return c.dot(x); }, gridView); auto p1Analytic = makeAnalyticGridViewFunction([&c](auto const& x) -> float { return c.dot(x); }, gridView);
using Writer = VtkUnstructuredGridWriter<GridView>; using Writer = VtkUnstructuredGridWriter<GridView>;
VtkTimeseriesWriter<Writer> seriesWriter(gridView, Vtk::BINARY, Vtk::FLOAT32); VtkTimeseriesWriter<Writer> seriesWriter(gridView, Vtk::BINARY, Vtk::FLOAT32);
seriesWriter.addPointData(p1Analytic, "q1"); seriesWriter.addPointData(p1Analytic, "q1");
seriesWriter.addCellData(p1Analytic, "q0"); seriesWriter.addCellData(p1Analytic, "q0");
std::string filename = prefix + "_" + std::to_string(GridView::dimension) + "d_binary32.vtu"; std::string filename = prefix + "_" + std::to_string(GridView::dimensionworld) + "d_binary32.vtu";
for (double t = 0.0; t < 5; t += 0.5) { for (double t = 0.0; t < 5; t += 0.5) {
seriesWriter.writeTimestep(t, filename); seriesWriter.writeTimestep(t, filename);
} }
...@@ -50,6 +50,6 @@ int main (int argc, char** argv) ...@@ -50,6 +50,6 @@ int main (int argc, char** argv)
using GridType = YaspGrid<3>; using GridType = YaspGrid<3>;
FieldVector<double,3> upperRight; upperRight = 1.0; FieldVector<double,3> upperRight; upperRight = 1.0;
auto numElements = filledArray<3,int>(8); auto numElements = filledArray<3,int>(8);
GridType grid(upperRight, numElements); GridType grid(upperRight, numElements, 0, 0);
write("yasp", grid.leafGridView()); write("yasp", grid.leafGridView());
} }
\ No newline at end of file
...@@ -31,7 +31,7 @@ int main(int argc, char** argv) ...@@ -31,7 +31,7 @@ int main(int argc, char** argv)
{ {
FieldVector<double,dim> lowerLeft; lowerLeft = 0.0; FieldVector<double,dim> lowerLeft; lowerLeft = 0.0;
FieldVector<double,dim> upperRight; upperRight = 1.0; FieldVector<double,dim> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim,unsigned int>(4); auto numElements = filledArray<dim,unsigned int>(8);
auto gridPtr = StructuredGridFactory<GridType>::createSimplexGrid(lowerLeft, upperRight, numElements); auto gridPtr = StructuredGridFactory<GridType>::createSimplexGrid(lowerLeft, upperRight, numElements);
auto& grid = *gridPtr; auto& grid = *gridPtr;
......
...@@ -40,11 +40,12 @@ void write (std::string prefix, GridView const& gridView) ...@@ -40,11 +40,12 @@ void write (std::string prefix, GridView const& gridView)
using namespace BasisFactory; using namespace BasisFactory;
auto basis = makeBasis(gridView, lagrange<1>()); auto basis = makeBasis(gridView, lagrange<1>());
FieldVector<double,GridView::dimension> c; FieldVector<double,GridView::dimensionworld> c;
if (GridView::dimension > 0) c[0] = 11.0; if (GridView::dimensionworld > 0) c[0] = 11.0;
if (GridView::dimension > 1) c[1] = 7.0; if (GridView::dimensionworld > 1) c[1] = 7.0;
if (GridView::dimension > 2) c[2] = 3.0; if (GridView::dimensionworld > 2) c[2] = 3.0;
assert(basis.dimension() > 0);
std::vector<double> vec(basis.dimension()); std::vector<double> vec(basis.dimension());
interpolate(basis, vec, [&c](auto const& x) { return c.dot(x); }); interpolate(basis, vec, [&c](auto const& x) { return c.dot(x); });
...@@ -60,7 +61,7 @@ void write (std::string prefix, GridView const& gridView) ...@@ -60,7 +61,7 @@ void write (std::string prefix, GridView const& gridView)
vtkWriter.addCellData(p1Interpol, "p0"); vtkWriter.addCellData(p1Interpol, "p0");
vtkWriter.addPointData(p1Analytic, "q1"); vtkWriter.addPointData(p1Analytic, "q1");
vtkWriter.addCellData(p1Analytic, "q0"); vtkWriter.addCellData(p1Analytic, "q0");
vtkWriter.write(prefix + "_" + std::to_string(GridView::dimension) + "d_" + std::get<0>(test_case) + ".vtu"); vtkWriter.write(prefix + "_" + std::to_string(GridView::dimensionworld) + "d_" + std::get<0>(test_case) + ".vtu");
} }
} }
...@@ -79,7 +80,7 @@ int main (int argc, char** argv) ...@@ -79,7 +80,7 @@ int main (int argc, char** argv)
{ {
FieldVector<double,dim.value> lowerLeft; lowerLeft = 0.0; FieldVector<double,dim.value> lowerLeft; lowerLeft = 0.0;
FieldVector<double,dim.value> upperRight; upperRight = 1.0; FieldVector<double,dim.value> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim.value,unsigned int>(4); auto numElements = filledArray<dim.value,unsigned int>(8);
auto gridPtr = StructuredGridFactory<GridType>::createSimplexGrid(lowerLeft, upperRight, numElements); auto gridPtr = StructuredGridFactory<GridType>::createSimplexGrid(lowerLeft, upperRight, numElements);
write("ug", gridPtr->leafGridView()); write("ug", gridPtr->leafGridView());
...@@ -92,8 +93,8 @@ int main (int argc, char** argv) ...@@ -92,8 +93,8 @@ int main (int argc, char** argv)
{ {
using GridType = YaspGrid<dim.value>; using GridType = YaspGrid<dim.value>;
FieldVector<double,dim.value> upperRight; upperRight = 1.0; FieldVector<double,dim.value> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim.value,int>(4); auto numElements = filledArray<dim.value,int>(8);
GridType grid(upperRight, numElements); GridType grid(upperRight, numElements, 0, 0);
write("yasp", grid.leafGridView()); write("yasp", grid.leafGridView());
}); });
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment