Commit b7ad0fc4 authored by Andreas Dedner's avatar Andreas Dedner

[!125] Bugfix/envforcmake

Merge branch 'bugfix/envforcmake' into 'master'

See merge request [!125]

  [!125]: Nonestaging/dune-python/merge_requests/125
parents 5b937092 ce281dbe
Pipeline #17016 failed with stage
in 15 seconds
......@@ -137,7 +137,11 @@ namespace Dune
if( (info.ndim != 2) || (info.shape[ 1 ] != numVertices) )
{
std::ostringstream msg;
msg << "buffer for geometry type " << type << " must be of shape (*, " << numVertices << ")";
msg << "buffer for geometry type " << type << " must be of shape (*, " << numVertices << ")\n";
if (info.ndim != 2)
msg << " shape dimension is not 2 but " << info.ndim;
else
msg << " shape dimension is 2 but shape[1] is " << info.shape[ 1 ];
throw std::invalid_argument( msg.str() );
}
......@@ -275,21 +279,33 @@ namespace Dune
else
throw std::invalid_argument( "Missing Key: 'vertices'" );
if( dict.contains( "elements" ) )
detail::GridFactory::insertElements( dict[ "elements" ], factory );
if( dict.contains( "lines" ) )
detail::GridFactory::insertElements( GeometryTypes::line, dict[ "lines" ], factory );
if( dict.contains( "line" ) )
detail::GridFactory::insertElements( GeometryTypes::line, dict[ "line" ], factory );
if( dict.contains( "triangles" ) )
detail::GridFactory::insertElements( GeometryTypes::triangle, dict[ "triangles" ], factory );
if( dict.contains( "triangle" ) )
detail::GridFactory::insertElements( GeometryTypes::triangle, dict[ "triangles" ], factory );
if( dict.contains( "tetrahedra" ) )
detail::GridFactory::insertElements( GeometryTypes::tetrahedron, dict[ "tetrahedra" ], factory );
if( dict.contains( "simplices" ) )
detail::GridFactory::insertElements( GeometryTypes::simplex( dimGrid ), dict[ "simplices" ], factory );
if( dict.contains( "tetra" ) )
{
std::cout << "reading tetras\n";
detail::GridFactory::insertElements( GeometryTypes::simplex( dimGrid ), dict[ "tetra" ], factory );
}
if( dict.contains( "quadrilaterals" ) )
detail::GridFactory::insertElements( GeometryTypes::quadrilateral, dict[ "quadrilaterals" ], factory );
if( dict.contains( "hexahedra" ) )
detail::GridFactory::insertElements( GeometryTypes::hexahedron, dict[ "hexahedra" ], factory );
if( dict.contains( "cubes" ) )
detail::GridFactory::insertElements( GeometryTypes::cube( dimGrid ), dict[ "cubes" ], factory );
......@@ -298,9 +314,6 @@ namespace Dune
if( dict.contains( "pyramid" ) )
detail::GridFactory::insertElements( GeometryTypes::prism, dict[ "pyramids" ], factory );
if( dict.contains( "elements" ) )
detail::GridFactory::insertElements( dict[ "elements" ], factory );
if( dict.contains( "boundaries" ) )
detail::GridFactory::insertBoundaries( dict[ "boundaries" ], factory );
}
......
......@@ -327,6 +327,11 @@ def is_installed(dir, module=None):
except KeyError:
return False
def get_cmake_command():
try:
return os.environ['DUNE_CMAKE']
except KeyError:
return 'cmake'
def get_module_path():
try:
......@@ -414,7 +419,7 @@ def configure_module(srcdir, builddir, prefix_dirs, definitions=None):
Returns:
Output of CMake command
"""
args = ['cmake']
args = [ get_cmake_command() ]
if definitions is None:
pass
elif isinstance(definitions, dict):
......@@ -448,7 +453,7 @@ def build_module(builddir, build_args=None):
if build_args is None:
build_args = get_default_build_args()
cmake_args = ['cmake', '--build', '.']
cmake_args = [get_cmake_command(), '--build', '.']
if build_args is not None:
cmake_args += ['--'] + build_args
......
......@@ -36,7 +36,8 @@ class Builder:
comm.barrier()
def compile(self, target='all'):
cmake_args = ["cmake", "--build", self.dune_py_dir, "--target", target]
cmake_command = dune.common.module.get_cmake_command()
cmake_args = [cmake_command, "--build", self.dune_py_dir, "--target", target]
if self.build_args is not None:
cmake_args += ['--'] + self.build_args
cmake = subprocess.Popen(cmake_args, cwd=self.generated_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
......
......@@ -18,7 +18,9 @@ def getDimgrid(constructor):
try:
dimgrid = len(constructor["vertices"][0])
except KeyError:
raise ValueError("Couldn't extract dimension of grid from constructor arguments, added dimgrid parameter")
pass
if not dimgrid:
raise ValueError("Couldn't extract dimension of grid from constructor arguments, added dimgrid parameter")
return dimgrid
def triangulation(grid, level=0):
......@@ -182,10 +184,10 @@ def levelView(hgrid,level):
return hgrid._levelView(level)
generator = SimpleGenerator("HierarchicalGrid", "Dune::Python")
def module(includes, typeName, *args):
def module(includes, typeName, *args, **kwargs):
includes = includes + ["dune/python/grid/hierarchical.hh"]
typeHash = "hierarchicalgrid_" + hashIt(typeName)
module = generator.load(includes, typeName, typeHash, *args)
module = generator.load(includes, typeName, typeHash, *args, **kwargs)
addAttr(module, module.LeafGrid)
# register reference element for this grid
......
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