Ejemplo n.º 1
0
            size = 5
            value = self.comm.rank + 1
            values = np.ones(size)*value

            A1 = prob.root.add('A1', IndepVarComp('x', values))
            C1 = prob.root.add('C1', ABCDArrayComp(size))

            prob.root.connect('A1.x', 'C1.a')
            prob.root.connect('A1.x', 'C1.b')

            prob.setup(check=False)
            prob.run()

            # check the first output array and store in result
            self.assertTrue(all(prob['C1.c'] == np.ones(size)*(value*2)))
            result = prob['C1.c']

            # gather the results from the separate processes/problems and check
            # for expected values
            results = self.comm.allgather(result)
            self.assertEqual(len(results), self.comm.size)

            for n in range(self.comm.size):
                expected = np.ones(size)*2*(n+1)
                self.assertTrue(all(results[n] == expected))


if __name__ == '__main__':
    from openmdao.test.mpi_util import mpirun_tests
    mpirun_tests()
Ejemplo n.º 2
0
    def test_parallel_array_comps_fwd(self):
        prob = self.prob
        prob.root.ln_solver.options['mode'] = 'fwd'
        prob.root.par.ln_solver.options['mode'] = 'fwd'
        prob.root.par.ser1.ln_solver.options['mode'] = 'fwd'
        prob.root.par.ser2.ln_solver.options['mode'] = 'fwd'

        prob.setup(check=False)
        prob.run()

        assert_rel_error(self, prob['total.obj'], 50.0, 1e-6)

    def test_parallel_derivs_fwd(self):
        prob = self.prob
        prob.root.ln_solver.options['mode'] = 'fwd'
        prob.root.par.ln_solver.options['mode'] = 'fwd'
        prob.root.par.ser1.ln_solver.options['mode'] = 'fwd'
        prob.root.par.ser2.ln_solver.options['mode'] = 'fwd'
        prob.driver.parallel_derivs(['par.ser1.p1.x', 'par.ser2.p1.x'])

        prob.setup(check=False)
        prob.run()

        assert_rel_error(self, prob['total.obj'], 50.0, 1e-6)


if __name__ == '__main__':
    from openmdao.test.mpi_util import mpirun_tests
    mpirun_tests()