def any_from_args(name, geometry, order, base='lagrange', force_bubble=False): """ Construct a particular polynomial space classes according to the arguments passed in. """ if name is None: name = PolySpace.suggest_name(geometry, order, base, force_bubble) if PolySpace._all is None: ps_files = get_paths('sfepy/discrete/fem/poly_spaces.py') ps_files += get_paths('sfepy/discrete/dg/poly_spaces.py') PolySpace._all = load_classes(ps_files, [PolySpace], ignore_errors=True, name_attr='name') table = PolySpace._all key = '%s_%s' % (base, PolySpace.keys[(geometry.dim, geometry.n_vertex)]) if (geometry.name == '1_2') and (key not in table): key = '%s_%s' % (base, 'tensor_product') if force_bubble: key += '_bubble' return table[key](name, geometry, order)
def from_conf(conf, regions): """ Create a Field subclass instance based on the configuration. """ if Field._all is None: from sfepy import get_paths from sfepy.base.base import load_classes field_files = [ ii for ii in get_paths('sfepy/discrete/fem/fields*.py') if 'fields_base.py' not in ii ] field_files += get_paths('sfepy/discrete/iga/fields*.py') field_files += get_paths('sfepy/discrete/structural/fields*.py') field_files += get_paths('sfepy/discrete/dg/fields.py') Field._all = load_classes(field_files, [Field], ignore_errors=True, name_attr='family_name') table = Field._all space = conf.get('space', 'H1') poly_space_base = conf.get('poly_space_base', 'lagrange') key = space + '_' + poly_space_base approx_order = parse_approx_order(conf.approx_order) ao, force_bubble, discontinuous = approx_order region = regions[conf.region] if region.kind == 'cell': # Volume fields. kind = 'volume' if discontinuous: cls = table[kind + '_' + key + '_discontinuous'] else: cls = table[kind + '_' + key] obj = cls(conf.name, conf.dtype, conf.shape, region, approx_order=approx_order[:2]) else: # Surface fields. kind = 'surface' cls = table[kind + '_' + key] obj = cls(conf.name, conf.dtype, conf.shape, region, approx_order=approx_order[:2]) return obj
def from_conf(conf, regions): """ Create a Field subclass instance based on the configuration. """ if Field._all is None: from sfepy import get_paths from sfepy.base.base import load_classes field_files = [ii for ii in get_paths('sfepy/discrete/fem/fields*.py') if 'fields_base.py' not in ii] field_files += get_paths('sfepy/discrete/iga/fields*.py') field_files += get_paths('sfepy/discrete/structural/fields*.py') Field._all = load_classes(field_files, [Field], ignore_errors=True, name_attr='family_name') table = Field._all space = conf.get('space', 'H1') poly_space_base = conf.get('poly_space_base', 'lagrange') key = space + '_' + poly_space_base approx_order = parse_approx_order(conf.approx_order) ao, force_bubble, discontinuous = approx_order region = regions[conf.region] if region.kind == 'cell': # Volume fields. kind = 'volume' if discontinuous: cls = table[kind + '_' + key + '_discontinuous'] else: cls = table[kind + '_' + key] obj = cls(conf.name, conf.dtype, conf.shape, region, approx_order=approx_order[:2]) else: # Surface fields. kind = 'surface' cls = table[kind + '_' + key] obj = cls(conf.name, conf.dtype, conf.shape, region, approx_order=approx_order[:2]) return obj
def get_examples(table): term_use = dict_from_keys_init(table.keys(), set) required, other = get_standard_keywords() for filename in locate_files('*py', get_paths('examples/')[0]): try: conf = ProblemConf.from_file(filename, required, other, verbose=False) except: continue ebase = filename.split('examples/')[1] lbase = os.path.splitext(ebase)[0] label = lbase.replace('/', '-') pyfile_name = ebase.split('/')[1] if pyfile_name in omits: continue use = conf.options.get('use_equations', 'equations') eqs_conf = getattr(conf, use) for key, eq_conf in six.iteritems(eqs_conf): term_descs = parse_definition(eq_conf) for td in term_descs: term_use[td.name].add(label) return term_use
def from_conf(conf, regions): """ Create a Field subclass instance based on the configuration. """ if Field._all is None: from sfepy import get_paths from sfepy.base.base import load_classes field_files = [ii for ii in get_paths("sfepy/discrete/fem/fields*.py") if "fields_base.py" not in ii] field_files += get_paths("sfepy/discrete/iga/fields*.py") field_files += get_paths("sfepy/discrete/structural/fields*.py") Field._all = load_classes(field_files, [Field], ignore_errors=True, name_attr="family_name") table = Field._all space = conf.get("space", "H1") poly_space_base = conf.get("poly_space_base", "lagrange") key = space + "_" + poly_space_base approx_order = parse_approx_order(conf.approx_order) ao, force_bubble, discontinuous = approx_order region = regions[conf.region] if region.kind == "cell": # Volume fields. kind = "volume" if discontinuous: cls = table[kind + "_" + key + "_discontinuous"] else: cls = table[kind + "_" + key] obj = cls(conf.name, conf.dtype, conf.shape, region, approx_order=approx_order[:2]) else: # Surface fields. kind = "surface" cls = table[kind + "_" + key] obj = cls(conf.name, conf.dtype, conf.shape, region, approx_order=approx_order[:2]) return obj
def from_conf(conf, regions): """ Create a Field subclass instance based on the configuration. """ if Field._all is None: import sfepy from sfepy.base.base import load_classes field_files = [ii for ii in sfepy.get_paths('sfepy/fem/fields*.py') if 'fields_base.py' not in ii] Field._all = load_classes(field_files, [Field], ignore_errors=True, name_attr='family_name') table = Field._all space = conf.get_default_attr('space', 'H1') poly_space_base = conf.get_default_attr('poly_space_base', 'lagrange') key = space + '_' + poly_space_base approx_order = parse_approx_order(conf.approx_order) ao, force_bubble, discontinuous = approx_order if isinstance(conf.region, tuple): # Surface fields. region_name, kind = conf.region region = regions[region_name] cls = table[kind + '_' + key] obj = cls(conf.name, conf.dtype, conf.shape, region, approx_order=approx_order[:2]) else: # Volume fields. kind = 'volume' if discontinuous: cls = table[kind + '_' + key + '_discontinuous'] else: cls = table[kind + '_' + key] obj = cls(conf.name, conf.dtype, conf.shape, regions[conf.region], approx_order=approx_order[:2]) return obj
from __future__ import absolute_import import os import sfepy from sfepy.base.base import load_classes, insert_static_method from .solvers import * from .eigen import eig solver_files = sfepy.get_paths('sfepy/solvers/*.py') remove = ['setup.py', 'solvers.py', 'petsc_worker.py'] solver_files = [name for name in solver_files if os.path.basename(name) not in remove] solver_table = load_classes(solver_files, [LinearSolver, NonlinearSolver, TimeSteppingSolver, EigenvalueSolver, OptimizationSolver], package_name='sfepy.solvers') def register_solver(cls): """ Register a custom solver. """ solver_table[cls.name] = cls def any_from_conf(conf, **kwargs): """Create an instance of a solver class according to the configuration.""" return solver_table[conf.kind](conf, **kwargs) insert_static_method(Solver, any_from_conf) del any_from_conf del sfepy
import sfepy import terms import extmods from terms import Terms, Term, CharacteristicFunction, vector_chunk_generator from terms_th import THTerm, ETHTerm from sfepy.base.base import load_classes term_files = sfepy.get_paths('sfepy/terms/terms*.py') term_table = load_classes(term_files, [Term], ignore_errors=True) del sfepy def register_term(cls): """ Register a custom term. """ term_table[cls.name] = cls
import sfepy import terms import extmods from terms import Terms, Term, CharacteristicFunction, vector_chunk_generator from cache import DataCache, DataCaches from sfepy.base.base import load_classes term_files = sfepy.get_paths('sfepy/terms/terms*.py') term_table = load_classes(term_files, [Term], ignore_errors=True) cache_files = sfepy.get_paths('sfepy/terms/caches*.py') cache_table = load_classes(cache_files, [DataCache], ignore_errors=True) del sfepy def register_term(cls): """ Register a custom term. """ term_table[cls.name] = cls
import sfepy import terms import extmods from terms import Terms, Term from terms_th import THTerm, ETHTerm from sfepy.base.base import load_classes term_files = sfepy.get_paths('sfepy/terms/terms*.py') term_table = load_classes(term_files, [Term], ignore_errors=True) del sfepy def register_term(cls): """ Register a custom term. """ term_table[cls.name] = cls