def __init__ (self, file, workdir=''): """ Constructor. Initializes the application. :param str file: Name of file :param str workdir: Optional parameter for working directory """ super(OOFEM, self).__init__(file, workdir) dr = liboofem.OOFEMTXTDataReader(file) self.oofem_pb = liboofem.InstanciateProblem(dr,liboofem.problemMode._processor,0) self.oofem_pb.checkProblemConsistency() self.oofem_mesh = self.oofem_pb.giveDomain(1) self.mesh = None # MuPIF representation of oofem mesh print ("Imported %d node and %d elements" % (self.oofem_mesh.giveNumberOfDofManagers(), self.oofem_mesh.giveNumberOfElements()))
def initialize(self, file='', workdir='', metaData={}, validateMetaData=True, **kwargs): super(oofem_api, self).initialize(file=file, workdir=workdir, metaData=metaData, validateMetaData=validateMetaData, **kwargs) if self.file != "": print("OOFEM reading input file '%s'" % self.file) dr = liboofem.OOFEMTXTDataReader(self.file) self.transp_model = liboofem.InstanciateProblem( dr, liboofem.problemMode._processor, 0) self.transp_model.checkProblemConsistency() print(self.transp_model.giveClassName()) active_m_step = self.transp_model.giveMetaStep(1) self.transp_model.initMetaStepAttributes(active_m_step) self.field_man = self.transp_model.giveContext().giveFieldManager()
from __future__ import print_function import liboofem import numpy as np # Instantiate uniform field ugrid = liboofem.UniformGridField() # Set 2D geometry ugrid.setGeometry(lo=(0, 0), hi=(1, 1), div=(2, 2)) # Set data: div is 2x2, hence 3x3=9 node grid with 9 values ugrid.setValues([0, .5, 0, .5, 1, .5, 0, .5, .5]) #ugrid.setValues([15,15,15,15,15,15,15,15,15]) print(ugrid.evaluateAtPos((0.5, 0.2))) dr = liboofem.OOFEMTXTDataReader("tmpatch05.in") transpModel = liboofem.InstanciateProblem(dr, liboofem.problemMode._processor, 0) transpModel.checkProblemConsistency() fieldMan = transpModel.giveContext().giveFieldManager() timeStep = transpModel.giveCurrentStep() #eField = transpModel.giveField(liboofem.FieldType.FT_Temperature,timeStep) #fieldMan.registerField(eField,liboofem.FieldType.FT_TransportProblemUnknowns) fieldMan.registerField(ugrid, liboofem.FieldType.FT_TemperatureAmbient) print(fieldMan.giveRegisteredKeys()) print(fieldMan.giveField(liboofem.FieldType.FT_TemperatureAmbient)) transpModel.solveYourself() transpModel.terminateAnalysis()
from __future__ import print_function import liboofem dr = liboofem.OOFEMTXTDataReader("inputs/tmpatch42.in") pb = liboofem.InstanciateProblem(dr, liboofem.problemMode._processor, 0) pb.checkProblemConsistency() pb.setRenumberFlag() pb.solveYourself() pb.terminateAnalysis() ts = pb.giveCurrentStep() for t in liboofem.FieldType.FT_Temperature, liboofem.FieldType.FT_HumidityConcentration: f = pb.giveField(liboofem.FieldType(t), ts) print(ts.targetTime, t, str(f)) #fm=pb.giveContext().giveFieldManager() #print fm #print fm.giveRegisteredKeys() # why is this one None? #print fm.giveField(liboofem.FieldType.FT_Displacements) #for i in range(100): # print fm.giveField(liboofem.FieldType(i)) print('Number of domains:', pb.giveNumberOfDomains()) # everything starts at 1 do = pb.giveDomain(1) print('Domain', do) e = do.giveElement(3) print('Element type', e.giveGeometryType()) for t in liboofem.FieldType.FT_Temperature, : #,liboofem.FieldType.FT_HumidityConcentration: f = pb.giveField(liboofem.FieldType(t), ts) print('Field at time', ts.targetTime, 'type', t, str(f))
a[1] = 15.0 a[0] = 10.0 print a[0], a[1] a.printYourself() c = liboofem.FloatArray(a) print c[0], c[1] c.printYourself() d = liboofem.FloatMatrix(2, 2) d.beUnitMatrix() d[0, 1] = 1.0 d.printYourself() b.beProductOf(d, a) b.printYourself() b.resize(4) b.zero() ind[0] = 1 ind[1] = 3 b.assemble(a, ind) b.printYourself() dr = liboofem.OOFEMTXTDataReader("patch100.in") problem = liboofem.InstanciateProblem(dr, liboofem.problemMode._processor, 0) problem.checkProblemConsistency() problem.setRenumberFlag() problem.solveYourself() problem.terminateAnalysis()
print(a[0], a[1]) a.printYourself() c = liboofem.FloatArray(a) print(c[0], c[1]) c.printYourself() d = liboofem.FloatMatrix(2, 2) d.beUnitMatrix() d[0, 1] = 1.0 d.printYourself() b.beProductOf(d, a) b.printYourself() b.resize(4) b.zero() ind[0] = 1 ind[1] = 3 b.assemble(a, ind) b.printYourself() print("\nSolving inputs/patch100.in") dr = liboofem.OOFEMTXTDataReader("inputs/patch100.in") problem = liboofem.InstanciateProblem(dr, liboofem.problemMode._processor, 0) problem.checkProblemConsistency() problem.setRenumberFlag() problem.solveYourself() problem.terminateAnalysis() print("\nProblem solved")