1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
##############################################################################
#
# Copyright (c) 2003-2018 by The University of Queensland
# http://www.uq.edu.au
#
# Primary Business: Queensland, Australia
# Licensed under the Apache License, version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Development until 2012 by Earth Systems Science Computational Center (ESSCC)
# Development 2012-2013 by School of Earth Sciences
# Development from 2014 by Centre for Geoscience Computing (GeoComp)
#
##############################################################################
from __future__ import print_function, division
__copyright__="""Copyright (c) 2003-2018 by The University of Queensland
http://www.uq.edu.au
Primary Business: Queensland, Australia"""
__license__="""Licensed under the Apache License, version 2.0
http://www.apache.org/licenses/LICENSE-2.0"""
__url__="https://launchpad.net/escript-finley"
import esys.escriptcore.utestselect as unittest
from esys.escriptcore.testing import *
from test_util import Test_util
from test_util import Test_Util_SpatialFunctions, Test_Util_SpatialFunctions_noGradOnBoundary_noContact
from test_symfuncs import Test_symfuncs
from esys.escript import *
from esys.ripley import MultiResolutionDomain
if HAVE_SYMBOLS:
from test_symfuncs import Test_symfuncs
else:
print("Skipping symbolic tests since sympy is not available")
class Test_symfuncs:
pass
from test_util_NaN_funcs import Test_util_NaN_funcs
NE=4 # number elements
mpiSize=getMPISizeWorld()
for x in [int(sqrt(mpiSize)),2,3,5,7,1]:
NX=x
NY=mpiSize//x
if NX*NY == mpiSize:
break
for x in [(int(mpiSize**(1/3.)),int(mpiSize**(1/3.))),(2,3),(2,2),(1,2),(1,1)]:
NXb=x[0]
NYb=x[1]
NZb=mpiSize//(x[0]*x[1])
if NXb*NYb*NZb == mpiSize:
break
def Rectangle(**kwargs):
kwargs['n0'] //= 2
kwargs['n1'] //= 2
m = MultiResolutionDomain(2, **kwargs)
return m.getLevel(1)
def Brick(**kwargs):
kwargs['n0'] //= 2
kwargs['n1'] //= 2
kwargs['n2'] //= 2
m = MultiResolutionDomain(3, **kwargs)
return m.getLevel(1)
class Test_UtilOnRipley(Test_util, Test_symfuncs, Test_util_NaN_funcs):
def setUp(self):
self.domain=Rectangle(n0=NE*NX-1, n1=NE*NY-1, l0=1., l1=1., d0=NX, d1=NY)
self.functionspace = FunctionOnBoundary(self.domain) # due to a bug in escript python needs to hold a reference to the domain
try:
self.workdir=os.environ['RIPLEY_WORKDIR']
except KeyError:
self.workdir='.'
def tearDown(self):
del self.functionspace
del self.domain
class Test_Util_SpatialFunctionsOnRipley2D(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
def setUp(self):
self.order=1
self.domain = Rectangle(n0=NE*NX-1, n1=NE*NY-1, l0=1., l1=1., d0=NX, d1=NY)
def tearDown(self):
del self.order
del self.domain
@unittest.skipIf(mpiSize > 1, "3D Multiresolution domains require single process")
class Test_Util_SpatialFunctionsOnRipley3D(Test_Util_SpatialFunctions_noGradOnBoundary_noContact):
def setUp(self):
self.order=1
self.domain = Brick(n0=NE*NXb-1, n1=NE*NYb-1, n2=NE*NZb-1, l0=1., l1=1., l2=1., d0=NXb, d1=NYb, d2=NZb)
def tearDown(self):
del self.order
del self.domain
if __name__ == '__main__':
run_tests(__name__, exit_on_failure=True)
|