Skip to content

Commit

Permalink
* Simply unnecessary and confusing things in Polygon shape creation
Browse files Browse the repository at this point in the history
* Tidy public/private things in fortran
* add safety check for stokes conditions.
  • Loading branch information
jmansour committed Jul 20, 2017
1 parent 722802d commit dcd96c8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions libUnderworld/Underworld/Function/src/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion libUnderworld/Underworld/Function/src/Shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 3 additions & 6 deletions underworld/function/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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." )
Expand All @@ -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)
4 changes: 3 additions & 1 deletion underworld/systems/_stokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dcd96c8

Please sign in to comment.