コード例 #1
0
ファイル: test_bcdata.py プロジェクト: joanibal/adflow
    def test_setBCData(self):
        "Test if bcdata is correctly set to data arrays"
        
        


        CFDSolver = ADFLOW(options=self.options)
        CFDSolver.addFamilyGroup('upstream',['inlet'])
        CFDSolver.addFamilyGroup('downstream',['outlet'])
        bc_data = CFDSolver.getBCData(groupNames=self.set_dvs.keys())
        
        for patch in bc_data:
            if patch.fam in self.set_dvs: 
                for arr in patch:
                    if arr.name in self.set_dvs[patch.fam]:
                        arr.data = self.set_dvs[patch.fam][arr.name]
        
        CFDSolver.setBCData(bc_data)
        # CFDSolver.setAeroProblem(self.ap)

        new_bc_data = CFDSolver.getBCData(groupNames=self.set_dvs.keys())

        ## check that the mesh bc match 
        for patch in new_bc_data:
            for arr in patch:
                np.testing.assert_array_equal(arr.data,
                 np.array(self.set_dvs[patch.fam][arr.name])
                 , err_msg=arr.name)
コード例 #2
0
ファイル: test_bcdata.py プロジェクト: joanibal/adflow
    def test_ap_bcvar_nodal_array(self):
        gridFile = os.path.join(baseDir, '../input_files/conic_conv_nozzle_mb_L4_array.cgns')
        options = copy.deepcopy(self.options)
        options['gridfile'] =  gridFile
        CFDSolver = ADFLOW(options=options)
        CFDSolver.addFamilyGroup('upstream',['inlet'])
        CFDSolver.addFamilyGroup('downstream',['outlet'])

  
        ap = self.ap
        group = 'outlet'
        BCVar = 'Pressure'
        # ap.bc_data = bc_data

        ap.setBCVar(BCVar,  70000.0, group)
        ap.addDV(BCVar,  name='outlet_pressure',  familyGroup=group,)
        
        # DVs = {'outlet_pressure':123000.0}
        DVs = {'outlet_pressure':np.arange(1,5*9+1)*10**5}

        ap.setDesignVars(DVs)
        assert (ap.getBCData()[group][BCVar] == DVs['outlet_pressure']).all()

        CFDSolver.setAeroProblem(ap)
        bc_data = CFDSolver.getBCData(groupNames=[group])
        for ii, d in enumerate(bc_data.getBCArraysFlatData(BCVar, familyGroup=group)):
            assert d == DVs['outlet_pressure'][ii]
コード例 #3
0
ファイル: test_bcdata.py プロジェクト: joanibal/adflow
    def test_getBCData(self):
        "Tests if mesh was read properly"
        CFDSolver = ADFLOW(options=self.options)
        CFDSolver.addFamilyGroup('upstream',['inlet'])
        CFDSolver.addFamilyGroup('downstream',['outlet'])

        bc_data = CFDSolver.getBCData(groupNames=self.initial_dvs.keys())

        ## check that the mesh bc match 
        for patch in bc_data:
            for arr in patch:
                np.testing.assert_array_equal(arr.data, np.array(self.initial_dvs[patch.fam][arr.name]))
コード例 #4
0
ファイル: test_bcdata.py プロジェクト: joanibal/adflow
    def test_setBCData_array(self):
        gridFile = os.path.join(baseDir, '../input_files/conic_conv_nozzle_mb_L4_array.cgns')
        options = copy.deepcopy(self.options)
        options['gridfile'] =  gridFile
        CFDSolver = ADFLOW(options=options)
        CFDSolver.addFamilyGroup('upstream',['inlet'])
        CFDSolver.addFamilyGroup('downstream',['outlet'])

        bc_data = CFDSolver.getBCData(groupNames=self.set_dvs.keys())
        for patch in bc_data:
            if patch.fam in self.set_dvs: 
                for arr in patch:
                    if arr.name in self.set_dvs[patch.fam]:
                        arr.data = self.set_dvs[patch.fam][arr.name]*np.ones(arr.size)
        
        CFDSolver.setBCData(bc_data)
        bc_data = CFDSolver.getBCData(groupNames=self.set_dvs.keys())

        for patch in bc_data:
            for arr in patch:
                np.testing.assert_array_equal(arr.data, np.ones(arr.size)*
                                                self.set_dvs[patch.fam][arr.name])
コード例 #5
0
ファイル: test_bcdata.py プロジェクト: joanibal/adflow
    def test_ap_bcvar_array(self):
        CFDSolver = ADFLOW(options=self.options)
        CFDSolver.addFamilyGroup('upstream',['inlet'])
        CFDSolver.addFamilyGroup('downstream',['outlet'])

        ap = self.ap
        group = 'outlet'
        BCVar = 'Pressure'
        # ap.bc_data = bc_data

        ap.setBCVar(BCVar,  70000.0, group)
        ap.addDV(BCVar,  name='outlet_pressure',  familyGroup=group,)
        
        # DVs = {'outlet_pressure':123000.0}
        DVs = {'outlet_pressure':np.arange(1,6)*10**5}

        ap.setDesignVars(DVs)
        print(ap.getBCData()[group][BCVar] == DVs['outlet_pressure'])
        assert (ap.getBCData()[group][BCVar] == DVs['outlet_pressure']).all()

        CFDSolver.setAeroProblem(ap)
        bc_data = CFDSolver.getBCData(groupNames=[group])
        for ii, d in enumerate(bc_data.getBCArraysFlatData(BCVar, familyGroup=group)):
            assert d == DVs['outlet_pressure'][ii]
コード例 #6
0
ファイル: test_bcdata.py プロジェクト: joanibal/adflow
    def test_ap_bcvar_scalar(self):
        CFDSolver = ADFLOW(options=self.options)
        CFDSolver.addFamilyGroup('upstream',['inlet'])
        CFDSolver.addFamilyGroup('downstream',['outlet'])

        ap = self.ap
        group = 'outlet'
        BCVar = 'Pressure'
        # ap.bc_data = bc_data

        ap.setBCVar(BCVar,  70000.0, group)
        ap.addDV(BCVar,  name='outlet_pressure',  familyGroup=group,)
        
        DVs = {'outlet_pressure':123000.0}

        ap.setDesignVars(DVs)

        assert ap.getBCData()[group][BCVar] == DVs['outlet_pressure']

        CFDSolver.setAeroProblem(ap)
        bc_data = CFDSolver.getBCData(groupNames=[group])
        
        for d in bc_data.getBCArraysFlatData(BCVar, familyGroup=group):
            assert d == DVs['outlet_pressure']