def __init__(self,\ name,\ saturation,\ regions,\ boundaryConditions,\ initialConditions = None,\ state = None,\ simulationType = None,\ calculationTimes = None,\ gravity = None,\ density = None,\ source = None,\ viscosity = None,\ outputs = None,\ description = None): """ Problem initialisation with : - name : name given by the user to the problem - saturation: determines the state to be modelled. Depending on the way the problem is defined, it can be modified. - boundary conditions: - initial conditions: - regions: all regions covering the entire mesh. Regions make up a partition of the mesh - gravity: default None - density: default None - viscosity: default None - sources default None - outputs default None """ # # name should be a string # if type(name) != bytes: raise TypeError("name should be a string ") self.name = name # # saturation # self.problemType = "saturated" self.saturation = "saturated" if type(saturation) == bytes: if saturation == "unsaturated" or saturation.lower()=="no": self.saturation = "unsaturated" self.problemType = "unsaturated" pass pass # # regions treatment # verifyClassList(regions, Region) regions_zones = [region.getZone() for region in regions] self.regions = regions # # gravity treatment # check = -1 if gravity: memberShip(gravity, Gravity) try: value=gravity.getValue() if type(value) not in [float, int]: raise TypeError(" value should be a float or an int ") meshdim = regions_zones[0].getSpaceDimension() value=[0.]*meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) gravity=Vector(value) except: pass pass else: meshdim = regions_zones[0].getSpaceDimension() value=[0.]*meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) gravity=Vector(value) print(value) self.gravity = gravity # # density treatment # if density: if type(density) == FloatType: density = Density(density, 'kg/m**3') memberShip(density, Density) check = 2*check pass self.density = density # # viscosity treatment # print(" dbg viscosity ",viscosity);#raw_input() if viscosity: if type(viscosity) == FloatType: viscosity = Viscosity(viscosity, 'kg/m/s') memberShip(viscosity, Viscosity) check = 3*check pass else: viscosity = Viscosity(1.0, 'kg/m/s') pass print(" dbg viscosity 1",viscosity);#raw_input() self.viscosity = viscosity # # Do we use intrinsic permeability # if self.saturation == "unsaturated": intrinsicPermeabilityCheck(self.regions, check) # # times definition # self.simulationType = simulationType # #raw_input("calculation times ") if calculationTimes: self.calculationTimes = calculationTimes self.simulationType = "Transient" pass else: self.calculationTimes = None self.simulationType = "Steady" pass self.steadyState = 1 if self.calculationTimes!= None: if type(calculationTimes) != list: raise TypeError(" calculationTimes should be a list ") CalculationTimes=toFloatList( self.calculationTimes) # for item in CalculationTimes: if type(item) != float: raise TypeError(" item should be a float ") pass self.calculationTimes = sorted( CalculationTimes) # print self.calculationTimes;#raw_input(" within the loop, calculation times are printed here") self.steadyState = 0 # The simulation is transient pass # # Permeability # if self.saturation == "unsaturated": # # only Richards for the moment # pass #raise Exception, " for the moment, undersaturated flows are not implemented" #regionPhysicalQuantitiesCheck([Permeability, IntrinsicPermeability], regions) # # boundaryConditions treatment # self.defaultBC = None boundaryConditions = toList(boundaryConditions) print(" problem type ",self.problemType) # raw_input(str(self.problemType)) print(dir(boundaryConditions[0])) # verification if all boundaries are treated. # If some are not, affect a default value (an homogeneous # neumann boundarycondition) boundaries = [] for boundaryElement in boundaryConditions: boundary = toList(boundaryElement.getBoundary()) for bound in boundary: boundaries.append(bound) pass # In case of structured mesh, not all the boundary could be defined for the problem if self.defaultBC: if not self.density: self.density = Density(1.) pass if not self.gravity: mesh_dim=regions[0].getZone().getMesh().getSpaceDimension() if mesh_dim==2: self.gravity=Gravity(Vector(0.,1.)) elif mesh_dim==3: self.gravity=Gravity(Vector(0.,0.,1.)) else: raise Warning('Dimension ????') pass pass # Verification if a pressure condition has been set # that density and gravity have been set # verifySomeOfPhysicalQuantitiesExists([Permeability, IntrinsicPermeability], regions) # verifyPressureBoundaryConditions(boundaryConditions, self.density, self.gravity) self.boundaryConditions = boundaryConditions # # initialConditions treatment # self.initialConditions = initialConditions # print " initialConditions",initialConditions;raw_input() # # source treatment # if source: verifyClassList(source, Source) self.source = source # # outputs treatment # if outputs: outputs1 = toList(outputs) verifyClassList(outputs1, _dicoproblem[type].ExpectedOutput) if not hasattr(self,'output_names'): self.output_names=[] for output in outputs1: if output.getName() in self.output_names: msg = '\n\nDifferent outputs should not share the same name.\n' msg+= 'End of the hydraulic problem run.\n\n' raise Warning(msg) self.output_names.append(output.getName()) pass # self.outputs = outputs return
def __init__(self,\ name,\ saturation,\ regions,\ boundaryConditions,\ initialConditions = None,\ state = None,\ simulationType = None,\ calculationTimes = None,\ gravity = None,\ density = None,\ source = None,\ intrinsicPermeability = None,\ viscosity = None,\ outputs = None,\ description = None): """ Problem initialisation with : - name : name given by the user to the problem - saturation: determines the state to be modelled. Depending on the way the problem is defined, it can be modified. - boundary conditions: - initial conditions: - regions: all regions covering the entire mesh. Regions make up a partition of the mesh - gravity: default None - density: default None - intrinsicPermeability: default None - viscosity: default None - sources default None - outputs default None """ # # name should be a string # if type(name) != bytes: raise TypeError("name should be a string ") self.name = name # # saturation # self.problemType = "saturated" self.saturation = "saturated" if type(saturation) == bytes: if saturation == "unsaturated" or saturation.lower() == "no": self.saturation = "unsaturated" self.problemType = "unsaturated" pass pass # # regions treatment # verifyClassList(regions, Region) regions_zones = [region.getZone() for region in regions] self.regions = regions # # gravity treatment # check = -1 if gravity: memberShip(gravity, Gravity) try: value = gravity.getValue() if type(value) not in [float, int]: raise TypeError(" value should be a float or an int ") meshdim = regions_zones[0].getSpaceDimension() value = [0.] * meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) gravity = Vector(value) except: pass pass else: meshdim = regions_zones[0].getSpaceDimension() value = [0.] * meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) gravity = Vector(value) print(value) pass self.gravity = gravity # # density treatment # if density: if type(density) == FloatType: density = Density(density, 'kg/m**3') memberShip(density, Density) check = 2 * check pass self.density = density # # intrinsicPermeability treatment # the introduction of the intrinsic permeability # is related to the introduction of the openfoam solver. # #print (intrinsicPermeability) #print (type(intrinsicPermeability)) #raw_input("problem type intrinsicPermeability") if intrinsicPermeability: if type(intrinsicPermeability) == FloatType: intrinsicPermeability = IntrinsicPermeability( intrinsicPermeability, 'm**2') memberShip(intrinsicPermeability, IntrinsicPermeability) check = 2 * check pass self.intrinsicPermeability = intrinsicPermeability #print (intrinsicPermeability) #print (type(intrinsicPermeability)) #raw_input("problem type intrinsicPermeability b") # # viscosity treatment # #print(" dbg viscosity ",viscosity);#raw_input() if viscosity: if type(viscosity) == FloatType: viscosity = Viscosity(viscosity, 'kg/m/s') memberShip(viscosity, Viscosity) check = 3 * check pass else: viscosity = Viscosity(1.0, 'kg/m/s') pass #print(" dbg viscosity 1",viscosity);#raw_input() self.viscosity = viscosity # # Do we use intrinsic permeability # if self.saturation == "unsaturated": intrinsicPermeabilityCheck(self.regions, check) # # times definition # self.simulationType = simulationType # #raw_input("calculation times ") if calculationTimes: self.calculationTimes = calculationTimes self.simulationType = "Transient" pass else: self.calculationTimes = None self.simulationType = "Steady" pass self.steadyState = 1 if self.calculationTimes != None: if type(calculationTimes) != list: raise TypeError(" calculationTimes should be a list ") CalculationTimes = toFloatList(self.calculationTimes) # for item in CalculationTimes: if type(item) != float: raise TypeError(" item should be a float ") pass self.calculationTimes = sorted(CalculationTimes) # print self.calculationTimes;#raw_input(" within the loop, calculation times are printed here") self.steadyState = 0 # The simulation is transient pass # # Permeability # if self.saturation == "unsaturated": # # only Richards for the moment # pass #raise Exception, " for the moment, undersaturated flows are not implemented" #regionPhysicalQuantitiesCheck([Permeability, IntrinsicPermeability], regions) # # boundaryConditions treatment # self.defaultBC = None boundaryConditions = toList(boundaryConditions) print(" problem type ", self.problemType) # raw_input(str(self.problemType)) print(dir(boundaryConditions[0])) # verification if all boundaries are treated. # If some are not, affect a default value (an homogeneous # neumann boundarycondition) boundaries = [] for boundaryElement in boundaryConditions: boundary = toList(boundaryElement.getBoundary()) for bound in boundary: boundaries.append(bound) pass # In case of structured mesh, not all the boundary could be defined for the problem if self.defaultBC: if not self.density: self.density = Density(1.) pass if not self.gravity: mesh_dim = regions[0].getZone().getMesh().getSpaceDimension() if mesh_dim == 2: self.gravity = Gravity(Vector(0., 1.)) elif mesh_dim == 3: self.gravity = Gravity(Vector(0., 0., 1.)) else: raise Warning('Dimension ????') pass pass # Verification if a pressure condition has been set # that density and gravity have been set # verifySomeOfPhysicalQuantitiesExists([Permeability, IntrinsicPermeability], regions) # verifyPressureBoundaryConditions(boundaryConditions, self.density, self.gravity) self.boundaryConditions = boundaryConditions # # initialConditions treatment # self.initialConditions = initialConditions # print " initialConditions",initialConditions;raw_input() # # source treatment # if source: verifyClassList(source, Source) self.source = source # # outputs treatment # if outputs: outputs1 = toList(outputs) verifyClassList(outputs1, _dicoproblem[type].ExpectedOutput) if not hasattr(self, 'output_names'): self.output_names = [] for output in outputs1: if output.getName() in self.output_names: msg = '\n\nDifferent outputs should not share the same name.\n' msg += 'End of the hydraulic problem run.\n\n' raise Warning(msg) self.output_names.append(output.getName()) pass pass # self.outputs = outputs return
def __init__(self,\ name,\ regions,\ boundaryConditions,\ initialConditions = None,\ state = None,\ simulationType = None,\ calculationTimes = None,\ gravity = None,\ density = None,\ sources = None,\ outputs = None,\ description = None): """ Problem initialisation with : - name : name given by the user to the problem - saturation: determines the state to be modelled. Depending on the way the problem is defined, it can be modified. - boundary conditions: - initial conditions: - regions: all regions covering the entire mesh. Regions make up a partition of the mesh - gravity: default None - density: default None - sources default None - outputs default None """ # # name should be a string # if type(name) != bytes: raise TypeError("name should be a string ") self.name = name # # mechanical # self.problemType = "elasticity" # # regions treatment # verifyClassList(regions, Region) regions_zones = [region.getZone() for region in regions] self.regions = regions # # gravity treatment # check = -1 if gravity: memberShip(gravity, Gravity) try: value = gravity.getValue() if type(value) not in [float, int]: raise TypeError(" value should be a float or an int ") meshdim = regions_zones[0].getSpaceDimension() value = [0.] * meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) gravity = Vector(value) except: pass pass else: meshdim = regions_zones[0].getSpaceDimension() value = [0.] * meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) pass gravity = Vector(value) print(value) pass # self.gravity = gravity # # density treatment # if density: if type(density) == FloatType: density = Density(density, 'kg/m**3') pass memberShip(density, Density) check = 2 * check pass self.solidDensity = density # # times definition # self.simulationType = simulationType # #raw_input("calculation times ") if calculationTimes: self.calculationTimes = calculationTimes self.simulationType = "Transient" pass else: self.calculationTimes = None self.simulationType = "Steady" pass self.steadyState = 1 if self.calculationTimes != None: if type(calculationTimes) != list: raise typeError(" calculationTimes should be a list ") CalculationTimes = toFloatList(self.calculationTimes) # for item in CalculationTimes: if type(item) != float: raise TypeError(" item should be a float ") pass self.calculationTimes = sorted(CalculationTimes) # print self.calculationTimes;#raw_input(" within the loop, calculation times are printed here") # # The simulation is transient # self.steadyState = 0 pass # # boundaryConditions treatment # self.defaultBC = None boundaryConditions = toList(boundaryConditions) print(" problem type ", self.problemType) print(dir(boundaryConditions[0])) # # boundaryConditions treatment # boundaries = [] for boundaryElement in boundaryConditions: boundary = toList(boundaryElement.getBoundary()) for bound in boundary: boundaries.append(bound) pass pass if self.defaultBC: if not self.density: self.density = Density(1.) pass if not self.gravity: mesh_dim = regions[0].getZone().getMesh().getSpaceDimension() if mesh_dim == 2: self.gravity = Gravity(Vector(0., 1.)) pass elif mesh_dim == 3: self.gravity = Gravity(Vector(0., 0., 1.)) pass else: raise Exception('Dimension ????') pass pass self.boundaryConditions = boundaryConditions # # initialConditions treatment # self.initialConditions = initialConditions # # sources treatment # if sources: verifyClassList(sources, Source) self.sources = sources # # outputs treatment # if outputs: outputs1 = toList(outputs) verifyClassList(outputs1, _dicoproblem[type].ExpectedOutput) if not hasattr(self, 'output_names'): self.output_names = [] pass for output in outputs1: if output.getName() in self.output_names: msg = '\n\nDifferent outputs should not share the same name.\n' msg += 'End of the hydraulic problem run.\n\n' raise Exception(msg) self.output_names.append(output.getName()) pass # self.outputs = outputs # return None
def __init__(self,\ name,\ regions,\ boundaryConditions,\ initialConditions,\ calculationTimes,\ chemistryDB,\ darcyVelocity = None, # darcy velocity speciesBaseAddenda = None,\ kineticLaws = None,\ timeUnit = None, \ activityLaw = None,\ porosityState = None,\ headVPorosity = None, state = None,\ simulationType = None,\ gravity = None,\ density = None,\ diffusionLaw = None,\ permeabilityLaw = None,\ sources = None,\ outputs = None,\ userProcessing = None,\ userFunctionList = None,\ variablePorosity = None,\ variableElasticity = None,\ temperature = None,\ description = None): """ Problem initialisation with : - name : name given by the user to the problem - saturation: determines the state to be modelled. Depending on the way the problem is defined, it can be modified. - boundary conditions: - initial conditions: - regions: all regions covering the entire mesh. Regions make up a partition of the mesh - gravity: default None - density: default None - sources default None - outputs default None """ # # name should be a string # if type(name) != bytes: raise TypeError("name should be a string ") self.name = name # # Elsasticy modulus variation # self.variableElasticity = variableElasticity # # # self.mpiEnv = None # simulation times to be recovered if type(calculationTimes) != list: raise TypeError(" simulationTimes must be a list of times ") i = 0 for item in calculationTimes: if type(item) not in [float,int]: raise TypeError(" calculationTimes must be a list of times ") calculationTimes[i] = calculationTimes[i] i += 1 pass previous = calculationTimes[0] for item in calculationTimes: if item < 0.: raise Exception('Error : Negative calculation time unexpected') if item < previous: raise Exception('Error : Decreasing calculation time unexpected') previous = item self.calculationTimes = calculationTimes pass # # we dont' consider a wellbore # self.wellbore = False # # species Addenda # if speciesBaseAddenda not in [None,[]]: verifyClassList(speciesBaseAddenda, Species) self.speciesBaseAddenda = speciesBaseAddenda pass else: self.speciesBaseAddenda = [] pass if type(name) != bytes: raise TypeError("name should be a string ") self.name = name # # mechanical # self.problemType = "thmc" # # Darcy and seepage Velocity treatment : # if isinstance(darcyVelocity,Velocity): self.darcyVelocity = darcyVelocity # elif isinstance(seepageVelocity,Velocity): # self.darcyVelocity = seepageVelocity # warnings.warn("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\ # seepage velocity is not handled and is equivalent to Darcy velocity for Elmer\n\ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n") elif type(darcyVelocity) == bytes: if darcyVelocity.lower() == "read": # # The Darcy velocity will be read from # the velocity.ep file # self.darcyVelocity = "read" pass elif darcyVelocity.lower() == "computed": # the Darcy velocity is transient self.darcyVelocity = "computed" pass else: self.darcyVelocity = None pass # # data Base # if type(chemistryDB) != bytes: raise TypeError("The chemistryDB argument of the THMC Problem must be a string ") self.chemistryDB = chemistryDB # # regions treatment # verifyClassList(regions, Region) regions_zones = [region.getZone() for region in regions] self.regions = regions # # gravity treatment # check = -1 if gravity: memberShip(gravity, Gravity) try: value=gravity.getValue() if type(value) not in [float, int]: raise TypeError(" value should be a float or an int ") meshdim = regions_zones[0].getSpaceDimension() value=[0.]*meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) gravity=Vector(value) except: pass pass else: meshdim = regions_zones[0].getSpaceDimension() value=[0.]*meshdim value[-1] = 9.81 if meshdim == 2: value.append(0.) gravity=Vector(value) print(value) pass # self.gravity = gravity # # activity law # if activityLaw: if not isinstance(activityLaw,ActivityLaw): raise Exception(" the activity law instantiation must be checked") ## else: ## self.activityLaw = TruncatedDavies() pass self.activityLaw = activityLaw # # density treatment # if density: if type(density) in [int,float]: density = Density(density, 'kg/m**3') memberShip(density, Density) check = 2*check pass self.solidDensity = density # # variable porosity: diffusion law # if diffusionLaw: if not isinstance(diffusionLaw,EffectiveDiffusionLaw): raise Exceptio(" the diffusion law instanciation must be checked") pass self.diffusionLaw = diffusionLaw self.permeabilityLaw = permeabilityLaw if headVPorosity!= None: if headVPorosity not in ["constant","variable","constante"]: self.headVPorosity = "constant" pass else: self.headVPorosity = headVPorosity pass else: self.headVPorosity = "constant" pass # # user processing set up # if userProcessing and type(userFunctionList) == types.ListType: self.userProcessing = True self.processingList = userFunctionList for processingFunction in range(len(self.processingList)): self.processingList[processingFunction]+="(self)" print(self.processingList[processingFunction]) pass pass else: self.userProcessing = False self.processingList = None pass # # Kinetics Laws # if kineticLaws != None : verifyClassList(kineticLaws, KineticLaw) self.kineticLaws = kineticLaws pass else : self.kineticLaws = None pass # # times definition # self.simulationType = simulationType # #raw_input("calculation times ") if calculationTimes: self.calculationTimes = calculationTimes self.simulationType = "Transient" else: self.calculationTimes = None self.simulationType = "Steady" self.steadyState = 1 if self.calculationTimes!= None: if type(calculationTimes) != list: raise typeError(" calculationTimes should be a list ") CalculationTimes=toFloatList( self.calculationTimes) # for item in CalculationTimes: if type(item) != float: raise TypeError(" item should be a float ") self.calculationTimes = sorted( CalculationTimes) # # The simulation is transient # self.steadyState = 0 pass # # boundaryConditions treatment # self.defaultBC = None boundaryConditions = toList(boundaryConditions) print(" problem type ",self.problemType) print(dir(boundaryConditions[0])) # # boundaryConditions treatment # boundaries = [] for boundaryElement in boundaryConditions: boundary = toList(boundaryElement.getBoundary()) for bound in boundary: boundaries.append(bound) pass if self.defaultBC: if not self.density: self.density = Density(1.) pass if not self.gravity: mesh_dim=regions[0].getZone().getMesh().getSpaceDimension() if mesh_dim==2: self.gravity=Gravity(Vector(0.,1.)) elif mesh_dim==3: self.gravity=Gravity(Vector(0.,0.,1.)) else: raise Warning('Dimension ????') pass pass self.boundaryConditions = boundaryConditions # # initialConditions treatment # self.initialConditions = initialConditions # # variable porosity # if porosityState: if type(porosityState) != bytes: raise TypeError(" the porosityState argument of the ChemicalTransportProblem must be a string ") porosityState = porosityState.lower() if (porosityState == 'constant') or (porosityState == 'variable'): self.porosityState = porosityState pass elif porosityState in ['steady',"cst"]: self.porosityState = 'constant' elif porosityState in ['transient',"var"]: self.porosityState = 'constant' else: ## self.porosityState = None mess = "porosityState badly defined (default : 'constant', else 'variable')" raise mess pass else: self.porosityState = 'constant' pass # # sources treatment # if sources != None: verifyClassList(sources, Source) self.sources = sources pass else : self.sources = None pass # # temperature # if temperature == None: self.temperature = "constant" pass else: self.temperature = temperature pass # # time unit # if timeUnit: if type(timeUnit) != bytes: raise TypeError(" the time unit argument of the ChemicalTransportProblem must be a string ") pass self.timeUnit = timeUnit # # outputs treatment # if outputs: outputs1 = toList(outputs) verifyClassList(outputs1, ExpectedOutput) if not hasattr(self,'output_names'): self.output_names=[] pass for output in outputs1: if output.getName() in self.output_names: msg = '\n\nDifferent outputs should not share the same name.\n' msg+= 'End of the hydraulic problem run.\n\n' raise msg self.output_names.append(output.getName()) pass # self.outputs = outputs # return None