#! /usr/bin/env python3 # from dolfin import * from mshr import * def domain ( ): #*****************************************************************************80 # ## domain demonstrates creating a domain by "subtraction". # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 23 October 2018 # # Author: # # John Burkardt # import matplotlib.pyplot as plt # # Define a region as a circle "minus" a rectangle and a square. # c1 = Point ( 0.0, 0.0 ) r1 = 5.0 sw = Point ( -3.0, -3.0 ) ne = Point ( -2.0, 2.0 ) c2 = Point ( 2.0, 2.0 ) r2 = 1.0 domain = Circle ( c1, r1, segments = 12 ) \ - Rectangle ( sw, ne ) \ - Circle ( c2, r2, segments = 12 ) # # Mesh the region. # mesh = generate_mesh ( domain, 10 ) # # Plot the mesh. # plot ( mesh, title = 'domain.py: logical combination of shapes' ) filename = 'domain_mesh.png' plt.savefig ( filename ) print ( ' Graphics saved as "%s"' % ( filename ) ) plt.close ( ) # # Terminate. # return def domain_test ( ): #*****************************************************************************80 # ## domain_test tests domain. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 23 October 2018 # # Author: # # John Burkardt # import dolfin import platform import time print ( time.ctime ( time.time() ) ) # # Report level = only warnings or higher. # level = 30 set_log_level ( level ) print ( '' ) print ( 'domain_test:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' FENICS version %s'% ( dolfin.__version__ ) ) print ( ' Demonstrate domain creattion by subtraction.' ) domain ( ) # # Terminate. # print ( '' ) print ( 'domain_test:' ) print ( ' Normal end of execution.' ) print ( '' ) print ( time.ctime ( time.time() ) ) return if ( __name__ == '__main__' ): domain_test ( )