11import json
22import types
33
4+
45class Problem :
56 """Generic problem problem, scalar or tensor depending on the pde. Warning, this problem needs to be used with the `set_pde` function in settings"""
67
7- def __init__ (self , rhs = None , exact = None ):
8+ def __init__ (self , rhs = None , exact = None , is_time_dependent = False ):
89 self .rhs = rhs
10+ self .is_time_dependent = is_time_dependent
911 self .exact = exact
1012 self .dirichlet_boundary = []
1113 self .neumann_boundary = []
1214 self .pressure_boundary = []
1315
14- self .dirichlet_boundary_lambda = []
15- self .neumann_boundary_lambda = []
16- self .pressure_boundary_lambda = []
16+ # self.dirichlet_boundary_lambda = []
17+ # self.neumann_boundary_lambda = []
18+ # self.pressure_boundary_lambda = []
1719
18- def set_dirichlet_value (self , id , value , is_dirichlet_dim = None ):
20+ def set_dirichlet_value (self , id , value , is_dirichlet_dim = None , linear_ramp_to = None ):
1921 """set the Dirichlet value value for the sideset id. Note the value must be a scalar, vector in 2D, or 3D depending on the problem. is_dirichlet_dim is a vector of boolean specifying which dimentions are fixed, only for vector-based problems."""
20- self .add_dirichlet_value (id , value , is_dirichlet_dim )
22+ self .add_dirichlet_value (id , value , is_dirichlet_dim , linear_ramp_to )
2123
22- def set_neumann_value (self , id , value ):
24+ def set_neumann_value (self , id , value , linear_ramp_to = None ):
2325 """set the Neumann value value for the sideset id. Note the value must be a scalar, vector in 2D, or 3D depending on the problem"""
24- self .add_neumann_value (id , value )
26+ self .add_neumann_value (id , value , linear_ramp_to )
2527
26- def set_pressure_value (self , id , value ):
28+ def set_pressure_value (self , id , value , linear_ramp_to = None ):
2729 """set the Pressure value value for the sideset id. Note the value must be a scalar"""
28- self .add_pressure_value (id , value )
30+ self .add_pressure_value (id , value , linear_ramp_to )
2931
30- def add_dirichlet_value (self , id , value , is_dirichlet_dim = None ):
32+ def add_dirichlet_value (self , id , value , is_dirichlet_dim = None , linear_ramp_to = None ):
3133 """set the Dirichlet value value for the sideset id. Note the value must be a scalar, vector in 2D, or 3D depending on the problem. is_dirichlet_dim is a vector of boolean specifying which dimentions are fixed, only for vector-based problems."""
3234
3335 tmp = {}
@@ -38,50 +40,58 @@ def add_dirichlet_value(self, id, value, is_dirichlet_dim=None):
3840 assert (len (value ) == len (is_dirichlet_dim ))
3941 tmp ["dimension" ] = is_dirichlet_dim
4042
43+ if linear_ramp_to is not None :
44+ tmp ["linear_ramp" ] = {"to" : linear_ramp_to }
45+
4146 if isinstance (value , types .LambdaType ) or isinstance (value , types .FunctionType ):
4247 pass
4348 # self.dirichlet_boundary_lambda.append(tmp)
4449 else :
4550 self .dirichlet_boundary .append (tmp )
4651
47- def add_neumann_value (self , id , value ):
52+ def add_neumann_value (self , id , value , linear_ramp_to = None ):
4853 """set the Neumann value value for the sideset id. Note the value must be a scalar, vector in 2D, or 3D depending on the problem"""
4954
5055 tmp = {}
5156 tmp ["id" ] = id
5257 tmp ["value" ] = value
5358
59+ if linear_ramp_to is not None :
60+ tmp ["linear_ramp" ] = {"to" : linear_ramp_to }
61+
5462 if isinstance (value , types .LambdaType ) or isinstance (value , types .FunctionType ):
5563 pass
5664 # self.neumann_boundary_lambda.append(tmp)
5765 else :
5866 self .neumann_boundary .append (tmp )
5967
60- def add_pressure_value (self , id , value ):
68+ def add_pressure_value (self , id , value , linear_ramp_to = None ):
6169 """set the Pressure value value for the sideset id. Note the value must be a scalar"""
6270
6371 tmp = {}
6472 tmp ["id" ] = id
6573 tmp ["value" ] = value
6674
75+ if linear_ramp_to is not None :
76+ tmp ["linear_ramp" ] = {"to" : linear_ramp_to }
77+
6778 if isinstance (value , types .LambdaType ) or isinstance (value , types .FunctionType ):
6879 pass
6980 # self.pressure_boundary_lambda.append(tmp)
7081 else :
7182 self .pressure_boundary .append (tmp )
7283
73-
74- def set_velocity (self , id , value , is_dim_fixed = None ):
84+ def set_velocity (self , id , value , is_dim_fixed = None , linear_ramp_to = None ):
7585 """set the velocity value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
76- self .add_dirichlet_value (id , value , is_dim_fixed )
86+ self .add_dirichlet_value (id , value , is_dim_fixed , linear_ramp_to )
7787
78- def set_displacement (self , id , value , is_dim_fixed = None ):
88+ def set_displacement (self , id , value , is_dim_fixed = None , linear_ramp_to = None ):
7989 """set the displacement value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
80- self .add_dirichlet_value (id , value , is_dim_fixed )
90+ self .add_dirichlet_value (id , value , is_dim_fixed , linear_ramp_to )
8191
82- def set_force (self , id , value ):
92+ def set_force (self , id , value , linear_ramp_to = None ):
8393 """set the force value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
84- self .add_neumann_value (id , value )
94+ self .add_neumann_value (id , value , linear_ramp_to )
8595
8696 def set_x_symmetric (self , id ):
8797 """x coorinate is fixed, y is allowed to move (Neumann)"""
@@ -108,8 +118,8 @@ def params(self):
108118 tmp = dict (
109119 (key , value )
110120 for (key , value ) in self .__dict__ .items ())
111- tmp .pop ('dirichlet_boundary_lambda' , None )
112- tmp .pop ('neumann_boundary_lambda' , None )
113- tmp .pop ('pressure_boundary_lambda' , None )
121+ # tmp.pop('dirichlet_boundary_lambda', None)
122+ # tmp.pop('neumann_boundary_lambda', None)
123+ # tmp.pop('pressure_boundary_lambda', None)
114124
115125 return tmp
0 commit comments