Пример #1
0
    err = domain.integral('<du_k du_k, sum:ij(d(du_i, x_j)^2)>_n J(x)' @ ns,
                          degree=max(degree, 3) * 2).eval(lhs=lhs)**.5
    treelog.user('errors: L2={:.2e}, H1={:.2e}'.format(*err))

    return err, cons, lhs


# If the script is executed (as opposed to imported), :func:`nutils.cli.run`
# calls the main function with arguments provided from the command line. For
# example, to keep with the default arguments simply run :sh:`python3
# platewithhole.py`. To select mixed elements and quadratic basis functions add
# :sh:`python3 platewithhole.py etype=mixed degree=2`.

if __name__ == '__main__':
    cli.run(main)

# Once a simulation is developed and tested, it is good practice to save a few
# strategic return values for regression testing. The :mod:`nutils.testing`
# module, which builds on the standard :mod:`unittest` framework, facilitates
# this by providing :func:`nutils.testing.TestCase.assertAlmostEqual64` for the
# embedding of desired results as compressed base64 data.


class test(testing.TestCase):
    @testing.requires('matplotlib')
    def test_spline(self):
        err, cons, lhs = main(nelems=4,
                              etype='square',
                              btype='spline',
                              degree=2,
Пример #2
0
    numeric.assert_allclose64(lhs,
      'eNolzsENwDAIA8CFEgkDJnSWqs/uv0KBvk4yFuALXLeK8d1nwanv5oLQ2ksl2wwdzVFzL8PaQ/iYEi0E'
      'pZU+punkqZi+HU7fZl/lF2TuWOR/N3x0slXhqb+eD+HPJKs=')

  def test_1d_p2(self):
    res, lhs = main(ndims=1, nelems=10, timescale=.1, degree=2, endtime=.01, withplots=False)
    numeric.assert_allclose64(res,
      'eNotj8mNBDAIBBMyEs1NLKN5Ov8UZsH7qqKNLbcd+Pk0LC71MVe7VIekmy/lARcuxd+S+VDCemdwXvKD'
      '0h5Kiw89gWEq17AqZdkcL+/dd46dSUx1xUtspRL7NHVmvyTkJcn5RCX8XYc+AYrfkZfNDwmhtSKBmi7k'
      '/i8W7Fuzpab39weWJTmO')
    numeric.assert_allclose64(lhs,
      'eNotz8kNxDAMA8CGHED3Uctin+m/hZiyXwMLAkXbYl8/Meb3iSXiCrnw9m0rVK6RSel9DPqY3VDd6SgJ'
      '3TRgOnK2FgU7SMcOO2aePOzpKqrJK9bR22dfi648OVx5e0Rf544y5rtns53+ElCEzv9M4P8DFyQ2QQ==')

  def test_2d_p1(self):
    res, lhs = main(ndims=2, nelems=4, timescale=.1, degree=1, endtime=.01, withplots=False)
    numeric.assert_allclose64(res,
      'eNpNkUsSwzAIQy9kZsCY31k6Xeb+V2iMA+lKBGn0SLIGyfiQkFwQQ1RwKygTXeADJkVcYIPceOtilK3g'
      'SJhDkNm/U8k2OlrtRevyxhHLoXjQVndde8+MK59Db18HBc4LZBDJ2jrVUmtfud4/ueotTvc+HHBlzIEn'
      '5fHTLPJWwf1a9xAasrvv6xftUjDmlRtySsxrdbitDhfhZRaimWas5y8Yn49Nwn7OuXvON1Sx7JOpeO5C'
      '9QwvtzO8VoXb6nAjGtqIB/r9AX6LebM=')
    numeric.assert_allclose64(lhs,
      'eNpVkcsRwyAMRBuCGf0RtWRyTP8tJBJISU6Wdtf7wJaBOh4ojq9pY+pGP4N6DkQMr6ljuhqkI7w8FCZL'
      'B40/u3yNjpZTyW4vXJcXbS7c+Sr5onR4OydFw5AhuHbsBLJiJwGLJ2JUc+uVa/3murhIVdykKSAHaUjp'
      'LOGdh9qmyaad90Iyi242OvoC/tUrV3rlurhIVdykqab386ud64OkYQAUA8O9n7OcQ267fw7gz6lkGx2t'
      '8qZ1+8U936ubdqU=')


if __name__ == '__main__':
  cli.run(main)