From dcd96c870c3471e51d6afd6926f9536ade7e1c1f Mon Sep 17 00:00:00 2001 From: jmansour Date: Thu, 20 Jul 2017 17:50:51 +1000 Subject: [PATCH] * Simply unnecessary and confusing things in Polygon shape creation * Tidy public/private things in fortran * add safety check for stokes conditions. --- libUnderworld/Underworld/Function/src/Shape.cpp | 4 ++-- libUnderworld/Underworld/Function/src/Shape.hpp | 2 +- underworld/function/shape.py | 9 +++------ underworld/systems/_stokes.py | 4 +++- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libUnderworld/Underworld/Function/src/Shape.cpp b/libUnderworld/Underworld/Function/src/Shape.cpp index 3a55bfd88..27acbc4d7 100644 --- a/libUnderworld/Underworld/Function/src/Shape.cpp +++ b/libUnderworld/Underworld/Function/src/Shape.cpp @@ -20,7 +20,7 @@ extern "C" { #include "Shape.hpp" -Fn::Polygon::Polygon( Function* fn, double* IN_ARRAY2, int DIM1, int DIM2, char* name ) +Fn::Polygon::Polygon( Function* fn, double* IN_ARRAY2, int DIM1, int DIM2 ) { _fn = fn; if(DIM1 < 3) @@ -42,7 +42,7 @@ Fn::Polygon::Polygon( Function* fn, double* IN_ARRAY2, int DIM1, int DIM2, char* XYZ startXYZ = { 0., 0., 0. }; XYZ endXYZ = { 0., 0., 0. }; - _stgshape = (void*) PolygonShape_New( (Name) name, + _stgshape = (void*) PolygonShape_New( (Name) NULL, (Dimension_Index)2, centre, 0., 0., 0., (Coord_List)IN_ARRAY2, diff --git a/libUnderworld/Underworld/Function/src/Shape.hpp b/libUnderworld/Underworld/Function/src/Shape.hpp index d3f99bc91..cdc7aa66e 100644 --- a/libUnderworld/Underworld/Function/src/Shape.hpp +++ b/libUnderworld/Underworld/Function/src/Shape.hpp @@ -17,7 +17,7 @@ namespace Fn { class Polygon: public Function { public: - Polygon(Function* _fn, double* IN_ARRAY2, int DIM1, int DIM2, char* name); + Polygon(Function* _fn, double* IN_ARRAY2, int DIM1, int DIM2); virtual func getFunction( IOsptr sample_input ); virtual ~Polygon(); private: diff --git a/underworld/function/shape.py b/underworld/function/shape.py index 8d8241738..7f4faa5db 100644 --- a/underworld/function/shape.py +++ b/underworld/function/shape.py @@ -15,7 +15,7 @@ import libUnderworld.libUnderworldPy.Function as _cfn from _function import Function as _Function -from _function import input +from _function import input as _input import numpy as _np class Polygon(_Function): @@ -69,7 +69,7 @@ def __init__(self, vertices, fn=None, *args, **kwargs): if fn: self._fn = _Function.convert(fn) else: - self._fn = input() + self._fn = _input() if not isinstance(vertices, _np.ndarray): raise TypeError( "Provided 'vertices' must be a numpy array." ) @@ -86,10 +86,7 @@ def __init__(self, vertices, fn=None, *args, **kwargs): threedeearray[:,0:2] = vertices[:,0:2] # create instance - import random - import string - self._id = "".join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) - self._fncself = _cfn.Polygon( self._fn._fncself, threedeearray, self._id ) + self._fncself = _cfn.Polygon( self._fn._fncself, threedeearray) # build parent super(Polygon,self).__init__(argument_fns=[fn,], *args, **kwargs) diff --git a/underworld/systems/_stokes.py b/underworld/systems/_stokes.py index 9332ff8f5..c710c5358 100644 --- a/underworld/systems/_stokes.py +++ b/underworld/systems/_stokes.py @@ -180,8 +180,10 @@ def __init__(self, velocityField, pressureField, fn_viscosity, fn_bodyforce=None elif type(cond) == uw.conditions.DirichletCondition: if cond.variable == self._velocityField: libUnderworld.StgFEM.FeVariable_SetBC( self._velocityField._cself, cond._cself ) - if cond.variable == self._pressureField: + elif cond.variable == self._pressureField: libUnderworld.StgFEM.FeVariable_SetBC( self._pressureField._cself, cond._cself ) + else: + raise ValueError("Provided condition does not appear to correspond to the system unknowns.") self._conditions = conditions