def __init__(self, number, *args, **KWs): self.number = number self.name = 'mg' + str(self.number) ScriptElement.__init__(self, *args, **KWs) # Set default variables self.requiresInitialSample = False self.getVar('momentGroups').append(self) self.computedVectors = set() self.operatorContainers = [] sampleFunctionName = ''.join(['_', self.id, '_sample']) sampleFunction = Function(name = sampleFunctionName, args = [], implementation = self.sampleFunctionContents) self.functions['sample'] = sampleFunction processFunctionName = ''.join(['_', self.id, '_process']) processFunction = Function(name = processFunctionName, args = [], implementation = self.processFunctionContents) self.functions['process'] = processFunction writeOutFunctionName = ''.join(['_', self.id, '_write_out']) writeOutFunction = Function(name = writeOutFunctionName, args = [('FILE*', '_outfile')], implementation = self.writeOutFunctionContents) self.functions['writeOut'] = writeOutFunction
def __init__(self, *args, **KWs): localKWs = self.extractLocalKWs(['name'], KWs) ScriptElement.__init__(self, *args, **KWs) # Set default variables self.dependenciesEntity = None self.operatorComponents = {} self.operatorVector = None self.resultVector = None self.operatorNumber = -1 # the name is only used for filter operators, which default to a normal segment object if not named in the XML self._name = None if localKWs: self._name = localKWs['name'] parent = self.parent parent.addOperator(self) if self._name: evaluateOperatorFunctionName = self._name else: evaluateOperatorFunctionName = ''.join(['_', parent.id, '_evaluate_', self.name]) evaluateOperatorFunction = Function(name = evaluateOperatorFunctionName, args = self.evaluateOperatorFunctionArguments, implementation = self.evaluateOperatorFunctionContents, description = self.description()) self.functions['evaluate'] = evaluateOperatorFunction if hasattr(self, 'calculateOperatorFieldFunctionArguments'): calculateOperatorFieldFunctionName = ''.join(['_', parent.id, '_calculate_', self.name, '_field']) calculateOperatorFieldFunction = Function(name = calculateOperatorFieldFunctionName, args = self.calculateOperatorFieldFunctionArguments, implementation = self.calculateOperatorFieldFunctionContents, description = self.description()) self.functions['calculateOperatorField'] = calculateOperatorFieldFunction
def __init__(self, **KWs): localKWs = self.extractLocalKWs(self.combinedClassInfo('instanceAttributes'), KWs) ScriptElement.__init__(self, **KWs) instanceDefaults = self.combinedClassInfo('instanceDefaults') [setattr(self, attrName, localKWs[attrName] if attrName in localKWs else instanceDefaults.get(attrName)) for attrName in self.combinedClassInfo('instanceAttributes')] self.silent = False
def __init__(self, *args, **KWs): localKWs = self.extractLocalKWs(['name', 'transverse','transform', 'aliases', 'volumePrefactor'], KWs) ScriptElement.__init__(self, *args, **KWs) self.name = localKWs['name'] self.transverse = localKWs.get('transverse', True) self.transform = localKWs.get('transform') self.aliases = localKWs.get('aliases', set()) self.aliases.add(self.name) self.volumePrefactor = localKWs.get('volumePrefactor') self.volumePrefactor = self.volumePrefactor if self.volumePrefactor else '1.0' self.representations = []
def __init__(self, *args, **KWs): # The MomentGroup and GeometryElement subclasses define name properties if not self.hasattr('name'): self.name = KWs['name'] del KWs['name'] if not 'parent' in KWs: KWs['parent'] = self.simulation ScriptElement.__init__(self, *args, **KWs) # Set default variables self.managedVectors = set() self.temporaryVectors = set() self.dimensions = [] self._basisForBasisCache = {} self.getVar('fields').append(self)
def __init__(self, *args, **KWs): localKWs = self.extractLocalKWs(['field', 'name', 'sharedCodeBlockKeyPath'], KWs) ScriptElement.__init__(self, *args, **KWs) # Set default state self.ipOperators = [] self.preDeltaAOperators = [] self.ipOperatorBasis = None self.deltaAOperator = None self.postDeltaAOperators = [] self.field = localKWs.get('field', None) self._name = localKWs.get('name', None) # These key paths are the 'paths' to the actual attributes for our # 'sharedCodeBlock' proxy property self.sharedCodeBlockKeyPath = localKWs.get('sharedCodeBlockKeyPath', 'deltaAOperator.primaryCodeBlock')
def __init__(self, *args, **KWs): localKWs = self.extractLocalKWs(['name', 'field', 'initialBasis', 'type'], KWs) field = localKWs['field'] self.name = localKWs['name'] self.field = field if not 'parent' in KWs: KWs['parent'] = field if KWs['parent'] is field: field.managedVectors.add(self) else: field.temporaryVectors.add(self) ScriptElement.__init__(self, *args, **KWs) # Set default variables self.components = [] self._needsInitialisation = True self._integratingComponents = False self.type = localKWs['type'] self.aliases = set() self.basesNeeded = set() self.initialBasis = None if localKWs.get('initialBasis') is not None: self.initialBasis = self.field.basisForBasis(localKWs['initialBasis']) self.basesNeeded.add(self.initialBasis) # Set default initialisation to be the zero initialisation template self.initialiser = VectorInitialisation(*args, **KWs) self.initialiser.vector = self intialiseFunctionName = ''.join(['_', self.id, '_initialise']) initialiseFunction = Function(name = intialiseFunctionName, args = [], implementation = self.initialiseFunctionContents, description = 'initialisation for ' + self.description(), predicate = lambda: self.needsInitialisation) self.functions['initialise'] = initialiseFunction basisTransformFunctionName = ''.join(['_', self.id, '_basis_transform']) basisTransformFunction = Function(name = basisTransformFunctionName, args = [('ptrdiff_t', 'new_basis')], implementation = self.basisTransformFunctionContents, predicate = lambda: self.needsTransforms) self.functions['basisTransform'] = basisTransformFunction
def __init__(self, *args, **KWs): ScriptElement.__init__(self, *args, **KWs) # Register ourselves with the transform multiplexer self.getVar('features')['TransformMultiplexer'].transforms.add(self) self.transformations = []
def __init__(self, *args, **KWs): ScriptElement.__init__(self, *args, **KWs) self.getVar('features')['Driver'] = self # Put ourselves at the start after the simulation element self.distributedDimensionNames = []
def __init__(self, **KWs): localKWs = self.extractLocalKWs(['codeString'], KWs) ScriptElement.__init__(self, **KWs) if 'codeString' in localKWs: self.codeString = localKWs.get('codeString')
def __init__(self, *args, **KWs): ScriptElement.__init__(self, *args, **KWs) self.getVar('features')[self.featureName] = self