Commit 53b68a21 authored by Michaël Sghaïer's avatar Michaël Sghaïer
Browse files

Remove duplicate exports of some enums and import dune.common as common

parent fd526b2c
......@@ -6,7 +6,7 @@ from scipy.sparse.linalg import spilu
from scipy.sparse.linalg import bicgstab
import dune.grid as grid
from dune.common import *
import dune.common as common
from shapefunctions import *
class P1Elements:
......@@ -152,6 +152,6 @@ if __name__ == "__main__":
f = grid.P1VTKFunction(grid_m, gridView, p1.u)
lgf = gridView.localGridFunction("u", f.evaluate)
lgf.addToVTKWriter(vtkwriter, vtkwriter.PointData)
lgf.addToVTKWriter(vtkwriter, common.DataType.PointData)
vtkwriter.write("fem2d")
......@@ -89,7 +89,7 @@ def timeloop(grid_m, gridView, tend):
vtkwriter = gridView.vtkWriter()
lgf = gridView.localGridFunction("concentration", lambda element, _: [c[mapper.index(element)]])
lgf.addToVTKWriter(vtkwriter, vtkwriter.CellData)
lgf.addToVTKWriter(vtkwriter, common.DataType.CellData)
counter = 0
t, dt = 0.0, 0.0
......@@ -97,7 +97,7 @@ def timeloop(grid_m, gridView, tend):
saveInterval = 0.1
saveStep = 0.1
vtkwriter.write("concentration", counter, vtkwriter.appendedraw)
vtkwriter.write("concentration", counter, common.OutputType.appendedraw)
counter += 1
while (t < tend):
......@@ -108,7 +108,7 @@ def timeloop(grid_m, gridView, tend):
t += dt
if (t >= saveStep):
vtkwriter.write("concentration", counter, vtkwriter.appendedraw)
vtkwriter.write("concentration", counter, common.OutputType.appendedraw)
saveStep += saveInterval
counter += 1
......
import numpy as np
from mpi4py import MPI
from dune.common import *
import dune.common as common
import dune.grid as grid
def c0(x):
......@@ -117,7 +117,7 @@ def timeloop(grid_m, gridView, tend):
vtkwriter = gridView.vtkWriter()
lgf = gridView.localGridFunction("concentration", lambda element, _: [c[mapper.index(element)]])
lgf.addToVTKWriter(vtkwriter, DataType.CellData)
lgf.addToVTKWriter(vtkwriter, common.DataType.CellData)
counter = 0
t, dt = 0.0, 0.0
......@@ -125,7 +125,7 @@ def timeloop(grid_m, gridView, tend):
saveInterval = 0.1
saveStep = 0.1
vtkwriter.write("concentration" + "-" + str(counter), OutputType.ascii)
vtkwriter.write("concentration" + "-" + str(counter), common.OutputType.ascii)
counter += 1
while (t < tend):
......@@ -135,7 +135,7 @@ def timeloop(grid_m, gridView, tend):
t += dt
if (t >= saveStep):
vtkwriter.write("concentration" + "-" + str(counter), OutputType.ascii)
vtkwriter.write("concentration" + "-" + str(counter), common.OutputType.ascii)
saveStep += saveInterval
counter += 1
......@@ -143,7 +143,7 @@ def timeloop(grid_m, gridView, tend):
if gridView.hierarchicalGrid.comm().rank == 0:
print("k=" + str(k) + " ; dt=" + str(dt))
vtkwriter.write("concentration" + "-" + str(counter), OutputType.ascii)
vtkwriter.write("concentration" + "-" + str(counter), common.OutputType.ascii)
if __name__ == "__main__":
alugrid_m = grid.get("ALUCubeGrid", dimgrid=2, dimworld=2) # Grid module
......
......@@ -73,20 +73,15 @@ namespace Dune
pybind11::class_< Writer > cls( scope, clsName );
cls.attr("CellData") = pybind11::cast(VTKDataType::CellData);
cls.attr("PointData") = pybind11::cast(VTKDataType::PointData);
cls.attr("CellVector") = pybind11::cast(VTKDataType::CellVector);
cls.attr("PointVector") = pybind11::cast(VTKDataType::PointVector);
cls.attr("ascii") = pybind11::cast(Dune::VTK::OutputType::ascii);
cls.attr("base64") = pybind11::cast(Dune::VTK::OutputType::base64);
cls.attr("appendedraw") = pybind11::cast(Dune::VTK::OutputType::appendedraw);
cls.attr("appendedbase64") = pybind11::cast(Dune::VTK::OutputType::appendedbase64);
cls.def( "write", [] ( Writer &writer, const std::string &name, Dune::VTK::OutputType outputType )
{ writer.write( name, outputType ); },
cls.def( "write",
[] ( Writer &writer, const std::string &name, Dune::VTK::OutputType outputType ) {
writer.write( name, outputType );
},
pybind11::arg("name"),
pybind11::arg("outputType")=VTK::ascii );
cls.def( "write", [] ( Writer &writer, const std::string &name, int number, Dune::VTK::OutputType outputType )
{
cls.def( "write",
[] ( Writer &writer, const std::string &name, int number, Dune::VTK::OutputType outputType ) {
std::stringstream s; s << name << std::setw(5) << std::setfill('0') << number;
writer.write( s.str(), outputType );
},
......@@ -94,6 +89,7 @@ namespace Dune
pybind11::arg("number"),
pybind11::arg("outputType")=VTK::ascii );
}
{
typedef SubsamplingVTKWriter< GridView > Writer;
......@@ -101,18 +97,12 @@ namespace Dune
pybind11::base< VTKWriter< GridView > >() );
cls.def( "write", [] ( Writer &writer, const std::string &name ) { writer.write( name ); } );
cls.def( "write", [] ( Writer &writer, const std::string &name, int number ) {
cls.def( "write",
[] ( Writer &writer, const std::string &name, int number ) {
std::stringstream s; s << name << std::setw(5) << std::setfill('0') << number;
writer.write( s.str() );
} );
cls.attr("CellData") = pybind11::cast(VTKDataType::CellData);
cls.attr("PointData") = pybind11::cast(VTKDataType::PointData);
cls.attr("CellVector") = pybind11::cast(VTKDataType::CellVector);
cls.attr("PointVector") = pybind11::cast(VTKDataType::PointVector);
cls.attr("ascii") = pybind11::cast(Dune::VTK::OutputType::ascii);
cls.attr("base64") = pybind11::cast(Dune::VTK::OutputType::base64);
cls.attr("appendedraw") = pybind11::cast(Dune::VTK::OutputType::appendedraw);
cls.attr("appendedbase64") = pybind11::cast(Dune::VTK::OutputType::appendedbase64);
});
}
}
......
Markdown is supported
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