Esempio n. 1
0
    def __call__(self, problem=None, data=None):
        from sfepy.base.base import select_by_names
        from sfepy.fem.variables import Variables
        from sfepy.fem.state import State
        from sfepy.fem.conditions import Conditions

        problem = get_default(problem, self.problem)

        conf_ebc = select_by_names(problem.conf.ebcs, self.ebcs)
        conf_epbc = select_by_names(problem.conf.epbcs, self.epbcs)
        ebcs = Conditions.from_conf(conf_ebc, problem.domain.regions)
        epbcs = Conditions.from_conf(conf_epbc, problem.domain.regions)

        conf_variables = select_by_names(problem.conf.variables, self.variable)
        problem.set_variables(conf_variables)
        variables = Variables.from_conf(conf_variables, problem.fields)
        variables.equation_mapping(ebcs, epbcs, problem.ts, problem.functions)
        state = State(variables)
        state.fill(0.0)
        state.apply_ebc()

        corr_sol = CorrSolution(name=self.name,
                                state=state.get_parts())

        self.save(corr_sol, problem, variables)

        return corr_sol
Esempio n. 2
0
    def __call__(self, problem=None, data=None):
        from sfepy.base.base import select_by_names
        from sfepy.fem.variables import Variables
        from sfepy.fem.state import State
        from sfepy.fem.conditions import Conditions

        problem = get_default(problem, self.problem)

        conf_ebc = select_by_names(problem.conf.ebcs, self.ebcs)
        conf_epbc = select_by_names(problem.conf.epbcs, self.epbcs)
        ebcs = Conditions.from_conf(conf_ebc, problem.domain.regions)
        epbcs = Conditions.from_conf(conf_epbc, problem.domain.regions)

        conf_variables = select_by_names(problem.conf.variables, self.variable)
        problem.set_variables(conf_variables)
        variables = Variables.from_conf(conf_variables, problem.fields)
        variables.equation_mapping(ebcs, epbcs, problem.ts, problem.functions)
        state = State(variables)
        state.fill(0.0)
        state.apply_ebc()

        corr_sol = CorrSolution(name=self.name, state=state.get_parts())

        self.save(corr_sol, problem, variables)

        return corr_sol
Esempio n. 3
0
    def select_bcs(self, ebc_names=None, epbc_names=None, lcbc_names=None, create_matrix=False):

        if ebc_names is not None:
            conf_ebc = select_by_names(self.conf.ebcs, ebc_names)
        else:
            conf_ebc = None

        if epbc_names is not None:
            conf_epbc = select_by_names(self.conf.epbcs, epbc_names)
        else:
            conf_epbc = None

        if lcbc_names is not None:
            conf_lcbc = select_by_names(self.conf.lcbcs, lcbc_names)
        else:
            conf_lcbc = None

        self.set_bcs(conf_ebc, conf_epbc, conf_lcbc)
        self.update_equations(self.ts, self.ebcs, self.epbcs, self.lcbcs, self.functions, create_matrix)
Esempio n. 4
0
    def select_variables(self, variable_names, only_conf=False):
        if type(variable_names) == dict:
            conf_variables = transform_variables(variable_names)

        else:
            conf_variables = select_by_names(self.conf.variables, variable_names)

        if not only_conf:
            self.set_variables( conf_variables )

        return conf_variables
Esempio n. 5
0
    def select_materials(self, material_names, only_conf=False):
        if type(material_names) == dict:
            conf_materials = transform_materials(material_names)

        else:
            conf_materials = select_by_names(self.conf.materials, material_names)

        if not only_conf:
            self.set_materials(conf_materials)

        return conf_materials
Esempio n. 6
0
    def select_variables(self, variable_names, only_conf=False):
        if type(variable_names) == dict:
            conf_variables = transform_variables(variable_names)

        else:
            conf_variables = select_by_names(self.conf.variables, variable_names)

        if not only_conf:
            self.set_variables(conf_variables)

        return conf_variables
Esempio n. 7
0
    def select_materials(self, material_names, only_conf=False):
        if type(material_names) == dict:
            conf_materials = transform_materials(material_names)

        else:
            conf_materials = select_by_names(self.conf.materials, material_names)

        if not only_conf:
            self.set_materials(conf_materials)

        return conf_materials
Esempio n. 8
0
    def select_bcs(self, ebc_names=None, epbc_names=None,
                   lcbc_names=None, create_matrix=False):

        if ebc_names is not None:
            conf_ebc = select_by_names(self.conf.ebcs, ebc_names)
        else:
            conf_ebc = None

        if epbc_names is not None:
            conf_epbc = select_by_names(self.conf.epbcs, epbc_names)
        else:
            conf_epbc = None

        if lcbc_names is not None:
            conf_lcbc = select_by_names(self.conf.lcbcs, lcbc_names)
        else:
            conf_lcbc = None

        self.set_bcs(conf_ebc, conf_epbc, conf_lcbc)
        self.update_equations(self.ts, self.ebcs, self.epbcs, self.lcbcs,
                              self.functions, create_matrix)
Esempio n. 9
0
    def test_consistency_d_dw( self ):
        from sfepy.base.base import select_by_names
        from sfepy.fem import eval_term_op

        ok = True
        pb = self.problem
        for aux in test_terms:
            term_template, (prefix, par_name, d_vars, dw_vars, mat_mode) = aux
            print term_template, prefix, par_name, d_vars, dw_vars, mat_mode

            var_names = nm.unique1d( d_vars + dw_vars )
            variables = select_by_names( pb.conf.variables, var_names )
            pb.set_variables( variables )

            vecs = {}
            for var_name in d_vars:
                var = pb.variables[var_name]
                n_dof = var.field.n_nod * var.field.dim[0]
                vecs[var_name] = nm.arange( n_dof, dtype = nm.float64 )
                var.data_from_data( vecs[var_name] )

            term1 = term_template % ((prefix,) + d_vars)
            pb.set_equations( {'eq': term1} )

            mat_args = {'m' : {'mode' : mat_mode}} 
            pb.time_update( extra_mat_args = mat_args )

            dummy = pb.create_state_vector()
            if prefix == 'd':
                val1 = eval_term_op( dummy, term1, pb )
            else:
                val1 = eval_term_op( dummy, term1, pb, call_mode = 'd_eval' )
                
            self.report( '%s: %s' % (term1, val1) )
            
            term2 = term_template % (('dw',) + dw_vars[:-1])

            vec = eval_term_op( dummy, term2, pb )
            val2 = nm.dot( vecs[par_name], vec )
            self.report( '%s: %s' % (term2, val2) )

            err = nm.abs( val1 - val2 ) / nm.abs( val1 )
            _ok = err < 1e-12
            self.report( 'relative difference: %e -> %s' % (err, _ok) )

            ok = ok and _ok
            
        return ok