Boundary conditions
Contains a class to evaluate symbolic and numeric linear velocity functions and their derivatives and classes to generate options for input files of pTatin3d.
Velocity
This module contains the class evaluating symbolic and numeric velocity field.
- class genepy.Velocity(Domain: Domain, Rotation: Rotation = None)
- class Velocity(Domain, Rotation=None)
Class to evaluate symbolic and numeric velocity function and its gradient. This class is the parent class of the different velocity classes and contains methods shared by all. Case specific methods are implemented in the corresponding child classes. The class inherits from
DomainandRotationclasses.Methods
- evaluate_gradient(self, u)
Evaluates the gradient of the velocity function in symbolic form returning a matrix of the shape
(dim,dim)such that:\[\left( \nabla \mathbf u \right)_{ij} = \frac{\partial u_i}{\partial x_j}\]- Parameters:
u – vector valued function of the velocity field
- Returns:
grad_u: matrix of the gradient of the velocity field shape
(dim,dim)
- evaluate_int_u_dot_n_faces(self, u)
Evaluates the integral of the dot product of the velocity field with the normal vector over the faces of the domain such that
\[I = \int_S \mathbf u \cdot \mathbf n \, dS\]The integral is computed over each face of the domain and stored in a dictionary:
int_u_dot_n = { 'xmin': int_u_dot_n_dxmin, 'xmax': int_u_dot_n_dxmax, 'ymin': int_u_dot_n_dymin, 'ymax': int_u_dot_n_dymax, 'zmin': int_u_dot_n_dzmin, 'zmax': int_u_dot_n_dzmax }
- Parameters:
u – Vector valued function of the velocity field. If not provided, the symbolic velocity field is evaluated with
evaluate_velocity_symbolic()- Returns:
int_u_dot_n: dictionary with the integral of the dot product of the velocity field with the normal vector over the faces of the domain
- Return type:
dict
- evaluate_u_dot_n(self, u)
Evaluates the dot product of the velocity field with the normal vector in symbolic form such that
\[\mathbf u \cdot \mathbf n = \sum_{i=1}^{d} u_i n_i\]with \(\mathbf u\) the vector valued velocity function, \(\mathbf n\) the normal vector to the boundary pointing outward the domain and \(d\) the number of spatial dimensions.
- Parameters:
u – Vector valued function of the velocity field. If not provided, the symbolic velocity field is evaluated with
evaluate_velocity_symbolic()- Returns:
u_dot_n: dot product of the velocity field with the normal vector
- get_velocity_orientation(self, horizontal=True, normalize=False)
Returns the orientation vector of the velocity field at the boundary
- Parameters:
horizontal (bool) – if True, only the horizontal components are returned (default: True)
normalize (bool) – if True, the vector is normalized (default: True)
- Returns:
uL: orientation of the velocity field at the boundary
- report_symbolic_functions(self)
Returns a string with the symbolic velocity function, its gradient and the boundary velocity orientation. Can be used with print() or written to a file.
- Returns:
string with the symbolic velocity function, its gradient and the boundary velocity orientation.
- Return type:
str
- velocity_boundary()
Note to me: When domain is ALE and the velocity is composite, the boundary velocity should be computed by face
- class genepy.VelocityLinear(Domain: Domain, u_norm, variation_dir: str, velocity_type: str, u_angle: float = 0.0, Rotation: Rotation = None)
- class VelocityLinear(Domain, u_norm, variation_dir, velocity_type, u_angle=0.0, Rotation=None)
Class to evaluate symbolic and numeric linear velocity function and its gradient in space. The velocity field is defined as a linear function of the coordinates. It can be used for 2D and 3D domains. Given a horizontal velocity field, the vertical velocity is computed by integrating the dot product of the velocity field with the normal vector over the faces of the domain. The class inherits from
DomainandRotation- Parameters:
Domain (Domain) – domain in which the velocity field is evaluated
u_norm (float) – velocity norm of the vector along boundaries
variation_dir (str) – direction in which the velocity varies (
"x","y","z")velocity_type (str) – velocity field orientation,
"extension"velocity is directed outward the domain,"compression"velocity is directed inward the domain
Optional
- Parameters:
u_angle (float) – angle in radians of the velocity field with the z axis
Rotation (Rotation) – Rotation object to rotate the referential
Examples
Assuming the class
Domainas been instanciated asDomainWithout rotation of the referential
u_norm = 1.0 # horizontal velocity norm u_angle = np.deg2rad(45.0) # velocity angle in [-pi/2, pi/2]. If 0, can be ommited u_dir = "z" # direction in which velocity varies u_type = "extension" # velocity orientation # Create VelocityLinear instance Vel = genepy.VelocityLinear(Domain,u_norm,u_dir,u_type,u_angle)
With rotation of the referential
# Rotation of the referential dim = 3 # Number of spatial dimensions r_angle = np.deg2rad(-15.0) # Rotation angle axis = np.array([0,1,0], dtype=np.float64) # Rotation axis # Create Rotation instance Rotation = gp.Rotation(dim,r_angle,axis) # Create VelocityLinear instance Vel = genepy.VelocityLinear(Domain,u_norm,u_dir,u_type,u_angle,Rotation)
Attributes
- norm: float
Velocity norm
- alpha: float
Velocity angle with the \(z\) axis in radians
- type: str
Type of velocity field (
"extension"or"compression")
- dir: int
Direction in which the velocity varies (
0,1,2) defined from the given directions"x","y","z"respectively.
- uO: numpy.ndarray
Velocity vector \(\mathbf u_O\) at \(\mathbf x = \mathbf O\). Shape
(dim,). Its value is computed at class initialization by the methodboundary_vector().
- uL: numpy.ndarray
Velocity vector \(\mathbf u_L\) at \(\mathbf x = \mathbf L\). Shape
(dim,). Its value is computed at class initialization by the methodboundary_vector().
- a: numpy.ndarray
Coefficients in vector form \(\mathbf a\) of the linear velocity function \(\mathbf u(x) = \mathbf a x + \mathbf b\). Shape
(dim,). Its value is computed at class initialization by the methodvelocity_coefficients().
- b: numpy.ndarray
Coefficients in vector form \(\mathbf b\) of the linear velocity function \(\mathbf u(x) = \mathbf a x + \mathbf b\). Shape
(dim,). Its value is computed at class initialization by the methodvelocity_coefficients().
- vertical_evaluated: bool
Flag to check if the vertical velocity has been evaluated
- u: numpy.ndarray
Vector valued function of the velocity field. Shape
(dim,). Contains sympy expressions.
- grad_u: numpy.ndarray
Matrix of the gradient of the velocity field. Shape
(dim,dim). Contains sympy expressions.
- u_dir_horizontal: numpy.ndarray
Horizontal vector of the velocity field orientation. Shape
(dim,).
- u_dir: numpy.ndarray
Full vector of the velocity field orientation. Shape
(dim,).
Methods
- boundary_vector(self, norm, alpha)
Computes a vector horizontal components from:
1D & 2D: only the
normis used,3D: the
normand anglealphawith the \(z\) axis (North-South) such that:
\[\begin{split}u_x &= \sqrt{||\mathbf u||^2 - u_z^2} \\ u_y &= 0 \\ u_z &= ||\mathbf u|| \cos(\alpha)\end{split}\]Warning
These values are always positive, special attention is required if different signs are needed. This is normally addressed with the
typeclass attribute.- Parameters:
norm (float) – velocity norm
alpha (float) – angle with the \(z\) axis in radians
- Returns:
boundary velocity, shape (dim,)
- Return type:
numpy.ndarray
- evaluate_velocity_and_gradient_symbolic(self)
Calls the methods:
evaluate_velocity_symbolicto evaluate the horizontal components of the velocityevaluate_vertical_velocityto evaluate the vertical component of the velocityevaluate_gradientto evaluate the gradient of the velocity vector
in symbolic form.
- evaluate_velocity_numeric(self)
Evaluates the velocity field numerically
- evaluate_velocity_symbolic(self)
Evaluates the velocity field in symbolic form returning a vector valued function of the form \(\mathbf u (x,y,z) = \mathbf a x + \mathbf b y + \mathbf c z + \mathbf d\) and shape
(1,dim).If a rotation is required i.e., an instance of the
Rotationclass with a non-zero angle is provided, the velocity is evaluated as:\[\mathbf u_R (\mathbf x) = \boldsymbol R \mathbf u (\mathbf x_R)\]where \(\mathbf x\) is the non-rotated coordinate system, \(\boldsymbol R\) is the rotation matrix, \(\mathbf x_R\) is the rotated coordinate system, \(\mathbf u\) is the velocity field before rotation and \(\mathbf u_R\) is the rotated velocity field.
The rotation of the coordinate system is performed by the method
rotate_referential(). The evaluation of the velocity field with the (rotated) coordinate system is done with the methodvelocity_function().
- evaluate_vertical_velocity(y, u=None)
Evaluates the vertical component of the velocity field. Can be used for numerical or symbolic evaluation. Calls the methods:
- Parameters:
y – coordinate of the vertical direction
u – (Optional), vector valued function of the velocity field. If not provided, the symbolic velocity field is evaluated with
evaluate_velocity_symbolic()
- Returns:
vertical component of the velocity field
- evaluate_vertical_velocity_coefficients(u=None)
Evaluates the coefficients of the vertical component of the velocity function \(a\) and \(b\) such that \(u_y(y) = a y + b\). To evaluate the coefficients, the following boundary conditions are used
\[\begin{split}u_y(L_y) &= 0 \\ u_y(O_y) &= \frac{1}{S_{xz}} \sum_f \int_S \mathbf u \cdot \mathbf n \, dS \\\end{split}\]where \(S_{xz}\) is the surface of the bottom face of the domain, \(O_y\) and \(L_y\) are the minimum and maximum values of the domain in the \(y\) direction.
\(a\) and \(b\) are then computed with
velocity_coefficients_1d()- Parameters:
u – (Optional), vector valued function of the velocity field. If not provided, the symbolic velocity field is evaluated with
evaluate_velocity_symbolic()- Returns:
a: slope of the vertical component of the velocity, b: constant of the vertical component of the velocity
- velocity_boundary(self)
Computes the boundary velocity vectors
uOanduLbased on thenormand the anglealphaprovided at class initialization.Note
The velocity field is symmetric on the boundaries i.e.,
uL = -uOfor compression anduO = -uLfor extension.
- velocity_coefficients(self)
For the vector valued velocity function \(\mathbf u(x) = \mathbf a x + \mathbf b\), computes coefficients \(\mathbf a\) and \(\mathbf b\) such that:
\[\begin{split}\mathbf a &= \frac{\mathbf u_L - \mathbf u_O}{\mathbf L - \mathbf O} \\ \mathbf b &= -\mathbf a \mathbf L + \mathbf u_L\end{split}\]with \(\mathbf u_O\) and \(\mathbf u_L\) computed by
boundary_vector()and \(\mathbf O\) and \(\mathbf L\) the origin and max values of the domain. Each component of the velocity field is computed by callingvelocity_coefficients_1d().
- velocity_coefficients_1d(self, uO, uL, O, L)
computes velocity function coefficients \(a\) and \(b\) of the linear function \(u(x) = ax + b\) for a given direction \(x \in [O,L]\) such that:
\[\begin{split}a &= \frac{u_L - u_O}{L - O} \\ b &= -aL + u_L\end{split}\]with \(u_O\) the velocity at \(x = O\) and \(u_L\) the velocity at \(x = L\) .
- Parameters:
uO (float) – velocity at the origin of the direction
uL (float) – velocity at the max value of the direction
O (float) – origin of the direction
L (float) – max value of the direction
- Returns:
a: slope of the component of the velocity, b: constant of the component of the velocity
- velocity_function(self, x)
computes the vector valued linear velocity function such that \(\mathbf u(x) = \mathbf a x + \mathbf b\). Calls the method
velocity_function_1d()for each direction.- Parameters:
x – coordinates of the direction in which the velocity varies
- Returns:
vector valued velocity function
- velocity_function_1d(self, x, a, b)
Computes the linear velocity field in 1 direction (scalar valued function) such that \(u(x) = ax + b\) for the given direction \(x\) and coefficients \(a\) and \(b\) computed by the method
velocity_coefficients_1d.- Parameters:
x – coordinate of the direction in which the velocity varies
a – slope of the component of the velocity
b – constant of the component of the velocity
- Returns:
scalar valued function of the velocity field
- class genepy.VelocityLinearAsymmetric(Domain: Domain, u_normL: float, u_normO: float, variation_dir: str, velocity_type: str, u_angleL: float = 0.0, u_angleO: float = 0.0, Rotation: Rotation = None)
- class VelocityLinearAsymmetric(Domain, u_normL, u_normO, variation_dir, velocity_type, u_angleL=0.0, u_angleO=0.0, Rotation=None)
Inherits from
VelocityLinearto evaluate a linear velocity field with different velocities at the boundaries. Both the norm and the angle can be different at the boundaries.- Parameters:
Domain (Domain) – domain in which the velocity field is evaluated
u_normL (float) – velocity norm of the vector at the boundary of maximum coordinate
u_normO (float) – velocity norm of the vector at the boundary of minimum coordinate
variation_dir (str) – direction in which the velocity varies (
"x","y","z")velocity_type (str) – velocity field orientation,
"extension"velocity is directed outward the domain,"compression"velocity is directed inward the domainu_angleL (float) – (Optional) angle in radians of the velocity field at the boundary of maximum coordinate
u_angleO (float) – (Optional) angle in radians of the velocity field at the boundary of minimum coordinate
Rotation (Rotation) – (Optional) Rotation class instance to rotate the referential
Example:
For an asymetric orthogonal shortening in the \(z\) direction from 1 cm/a to 0 cm/a at the boundaries, assuming that the class
Domainhas been instanciated asdomain:cma2ms = 1e-2 / (3600.0 * 24.0 * 365.0) # cm/a to m/s conversion u_normL = 1.0*cma2ms u_normO = 0.0 u_dir = "z" u_type = "compression" Vel = gp.VelocityLinearAsymmetric(domain,u_normL,u_normO,u_dir,u_type)
Attributes
- normL: float
Velocity norm at the boundary of maximum coordinate
- normO: float
Velocity norm at the boundary of minimum coordinate
- alphaL: float
Velocity angle with the \(z\) axis in radians at the boundary of maximum coordinate. Default:
0.0.
- alphaO: float
Velocity angle with the \(z\) axis in radians at the boundary of minimum coordinate. Default:
0.0.
- class genepy.VelocityTimeDependant(Domain: Domain, Rotation: Rotation = None)
- class VelocityTimeDependant(Domain, Rotation=None)
Class to construct and evaluate time dependant velocity function. This class is the parent class of all time dependant velocity classes and inherits from the class
Velocity.- Parameters:
Methods
- sum_functions(self, user_func, user_args)
Abstract method to sum user defined functions. The functions to sum should return objects of the same shape and type.
Considering the functions \(f_1(x), f_2(x), \ldots , f_n(x)\) this method computes:
\[u(x) = \sum_{i=1}^{n} f_i(x)\]where \(x\) represents the variable(s) of the function.
- Parameters:
user_func (list) – list of user defined functions
user_args (list) – list of arguments to pass to the functions
- class genepy.VelocityInversion(Domain: Domain, phase1: VelocityLinear, phase2: VelocityLinear, breakpoints, slopes, Rotation: Rotation = None)
- class VelocityInversion(Domain, phase1, phase2, breakpoints, slopes, Rotation=None)
Class to construct and evaluate a time dependant velocity function with two phases by summing two
arctangent functions.- Parameters:
Domain (Domain) – domain in which the velocity field is evaluated
phase1 (VelocityLinear) –
Velocityclass instance of the first phasephase2 (VelocityLinear) –
Velocityclass instance of the second phasebreakpoints (list) – list of two breakpoints in time
slopes (list) – list of two slopes at the breakpoints
Rotation (Rotation) – (Optional) Rotation class instance to rotate the referential
Attributes
- phases: list
List containing the 2 class instances of the velocity phases. Shape
[phase1:Velocity, phase2:Velocity].
- breakpoints: list
List of the two breakpoints in time. Shape
[breakpoint1:float, breakpoint2:float]
- slopes: list
List of the two slopes at the breakpoints. Shape
[slope1:float, slope2:float]
- u: numpy.ndarray
Vector valued function of the velocity field. Shape
(dim,). Contains sympy expressions.
- grad_u: numpy.ndarray
Matrix of the gradient of the velocity field. Shape
(dim,dim). Contains sympy expressions.
- u_dir_horizontal: list
List of horizontal vectors of the velocity field orientation for each phase. Shape
[(dim,), (dim,)].
- u_dir: numpy.ndarray
List of the full vector of the velocity field orientation for each phase. Shape
[(dim,), (dim,)].
Methods
- evaluate_velocity_and_gradient_symbolic(self)
Calls the methods:
evaluate_velocity_symbolicto evaluate the time dependant velocity functionevaluate_gradientto evaluate the gradient of the velocity function
- Returns:
u, grad_u, time dependant velocity function and its gradient
- evaluate_velocity_symbolic(self)
Evaluates the time dependant velocity function in symbolic form. Calls the methods
evaluate_velocity_symbolicandevaluate_vertical_velocityfor each phase. Then evaluates the time dependant velocity function with the methodvelocity_function.- Returns:
time dependant velocity function
- get_time_zero_velocity(self, report=False)
Computes the time at which the velocity function evaluates to zero. The result is obtained by solving the equation \(f(t) = 0\) with the iterative Newton-Raphson method. The initial guess is set to the first breakpoint in time because it is the most likely to converge (steep part of the function).
- Parameters:
report (bool) – if True, the Newton-Raphson method reports the convergence of the solution (default:
False)- Returns:
time at which the velocity function evaluates to zero
- plot_1D_velocity(self, time)
Plots the velocity function in 1D over time. If the spatial dimension is more than 1 (i.e., 2D and 3D) only the norm of the velocity function is evaluated to allow plotting. The sign convention for the plot is:
extension: positive velocity
compression: negative velocity
Displays two plots:
the velocity over time in m/s
the velocity over time in cm/a
On both plots the point at which the velocity evaluates to zero is marked with a red circle.
- Parameters:
time (numpy.ndarray) – time array
- velocity_function(self, time, bound)
Evaluates a time dependant velocity function \(u(t)\) with two phases by summing two arctangent functions such that
\[\begin{split}f_1(t) &= b_1 \left( \frac{1}{2} - \frac{\tan^{-1} \left(s_1(t-t_1) \right)}{\pi} \right) \\ f_2(t) &= b_2 \left( \frac{1}{2} + \frac{\tan^{-1} \left(s_2(t-t_2) \right)}{\pi} \right) \\ u(t) &= f_1(t) + f_2(t)\end{split}\]where \(t_i\) are the breakpoints in time, \(s_i\) are the arctangent slopes at the breakpoints and \(b_i\) are the bounds of the functions (min and max values i.e., the steady state velocities of each phase).
- Parameters:
time (float) – time at which the velocity function is evaluated, can be symbolic or numeric
bound (list) – list of two bounds of the velocity function
- Returns:
time-dependant velocity function
- velocity_function_derivative(self, time, bound)
Evaluates the derivative with respect to time of the velocity function. The derivative is computed by summing the derivatives of the two arctangent functions defined in
velocity_functionsuch that\[\begin{split}f'_1(t) &= -\frac{b_1 s_1}{\pi (1 + (s_1(t-t_1))^2)} \\ f'_2(t) &= \frac{b_2 s_2}{\pi (1 + (s_2(t-t_2))^2)}\end{split}\]- Parameters:
time (float) – time at which the function is evaluated, can be symbolic or numeric
bound (list) – list of two bounds of the stady-state velocity functions
- Returns:
derivative with respect to time of the velocity function
- class genepy.VelocityCompose(Domain: Domain, Velocities: list[Velocity], Rotation: Rotation = None, method='sum')
- class VelocityCompose(Domain, Velocities, Rotation=None, method='sum')
Class to construct and evaluate a velocity function composed by multiple velocity functions. The composition method is defined by the
methodparameter.- Parameters:
Attributes
- nfuncs: int
Number of velocity functions to compose
- method: str
Method to compose the velocity functions. Default is
"sum".
Methods
- sum_velocities(self)
Sums the velocity functions of
velocityclass instances from the listvelocities.
Options generation
Bounary conditions wrapper
This class is a wrapper to generate options of the boundary conditions for input files of pTatin3d.
- class genepy.ModelBCs(velocity_bcs: list[StokesBoundaryCondition], energy_bc: TemperatureBC = None, model_name: str = 'model_GENE3D')
- class ModelBCs(velocity_bcs: list[StokesBoundaryCondition], energy_bc: TemperatureBC = None, model_name: str = 'model_GENE3D')
Class to generate options for the boundary conditions of a pTatin3d model. Enforce the model name for all boundary conditions objects.
- Parameters:
velocity_bcs (list[StokesBoundaryCondition]) – list of instances of class
StokesBoundaryConditionfor the Stokes boundary conditions of the model.energy_bc (TemperatureBC) – instance of class
TemperatureBCfor the energy boundary conditions of the model.model_name (str) – name of the model (default: model_GENE3D)
Attributes
- model_name: str
Name of the model
- u_bcs: list[StokesBoundaryCondition]
List of instances of class
StokesBoundaryCondition(and its children) for the Stokes problem boundary conditions.
- energy_bc: TemperatureBC
Instance of class
TemperatureBCfor the energy boundary conditions
Example
The following example assumes that the velocity function
u, its gradientgrad_uand the orientation vectoruLare defined elsewhere in the code.import genepy as gp # Velocity boundary conditions bcs = [ gp.Dirichlet(23,"Zmax",["x","z"],u), gp.Dirichlet(37,"Zmin",["x","z"],u), gp.NavierSlip(32,"Xmax",grad_u,uL), gp.NavierSlip(14,"Xmin",grad_u,uL), gp.DirichletUdotN(33,"Bottom"), ] # Temperature boundary conditions Tbcs = gp.TemperatureBC({"ymax":0.0, "ymin":1450.0}) # collect all boundary conditions all_bcs = gp.ModelBCs(bcs,Tbcs)
- class genepy.BoundaryCondition(model_name: str = 'model_GENE3D')
- class BoundaryCondition(model_name: str = 'model_GENE3D')
Abstract class to generate options for pTatin3d boundary conditions. Parent class of
StokesBoundaryConditionandTemperatureBC.
- format_expression(expression: str)
Format the given expression to be used in pTatin3d input file. Basically, it removes spaces between characters.
- Parameters:
expression (str) – expression to format
- Returns:
formatted expression
- Return type:
str
- is_expression(expression: str)
Check if the given expression contains one or several variables of the list
["x","y","z","t","p"].- Parameters:
expression (str) – expression to check
- Returns:
True if the expression contains one or several variables of the list, False otherwise
- Return type:
bool
Stokes boundary conditions
This class is parent of all Stokes boundary conditions classes:
- class genepy.StokesBoundaryCondition(tag: int = 0, mesh_file: str = 'path_to_file', model_name: str = 'model_GENE3D')
- class StokesBoundaryCondition(tag: int = 0, mesh_file: str = 'path_to_file', model_name: str = 'model_GENE3D')
Class to generate the options for pTatin3d boundary condition for the Stokes problem.
- Parameters:
tag (int) – tag of the boundary condition given by gmsh
mesh_file (str) – path to the mesh file containing the facets of the boundary
model_name (str) – name of the model (default: model_GENE3D)
Attributes
- tag: int
Tag of the boundary condition
- prefix: str
Prefix: “bc” for the options
- bc_type: int
Type of the boundary condition in the model
- bc_name: str
Name of the boundary condition in the model
- mesh_file: str
Path to the mesh file containing the facets of the boundary
- sprint_option(self)
Returns a string formatted for pTatin3d input file using PETSc options format. All subclasses of
StokesBoundaryConditioncall this method.- Returns:
string formatted for pTatin3d input file
- Return type:
str
Dirichlet
Classes to generate options for Dirichlet boundary conditions.
Inherits from class StokesBoundaryCondition.
- class genepy.Dirichlet(tag: int, name: str, components, velocity, mesh_file: str = 'path_to_file', model_name: str = 'model_GENE3D')
- class Dirichlet(tag: int, name: str, components, velocity, mesh_file: str = 'path_to_file', model_name: str = 'model_GENE3D')
Class to generate the options for pTatin3d for a Dirichlet type boundary condition. Inherited from
StokesBoundaryCondition.- Parameters:
tag (int) – tag of the boundary condition given by gmsh
name (str) – name of the boundary condition in the model
components (list) – list of string of the velocity components on which to impose the Dirichlet condition. Possible values
["x","y","z"]velocity – velocity to impose, expected shape:
(1,dim)mesh_file (str) – path to the mesh file containing the facets of the boundary
model_name (str) – name of the model (default: model_GENE3D)
Attributes
- tag: int
Tag of the boundary condition
- prefix: str
Prefix: “bc_dirichlet” for the options
- bc_type: int
Type of the boundary condition in the model. For Dirichlet: 7
- bc_name: str
Name of the boundary condition in the model, name is arbitrary but providing one is mandatory
- mesh_file: str
Path to the mesh file containing the facets of the boundary
- sprint_option(self)
Returns the string to be added to the options file descibing the Dirichlet boundary condition. Calls
genepy.StokesBoundaryCondition.sprint_option()first.- Returns:
string to be added to the options file
- Return type:
str
Neumann
Class to generate options for Neumann boundary conditions.
Inherits from class StokesBoundaryCondition.
- class genepy.Neumann(tag: int, name: str, dev_stress_expression=None, mesh_file: str = 'path_to_file', model_name: str = 'model_GENE3D')
- class Neumann(tag: int, name: str, dev_stress_expression=None, mesh_file: str = 'path_to_file', model_name: str = 'model_GENE3D')
Class to generate the options for pTatin3d Neumann boundary condition for the Stokes problem.
- Parameters:
tag (int) – tag of the boundary condition given by gmsh
name (str) – name of the boundary condition in the model (optional)
dev_stress_expression (str) – expression for the deviatoric stress
mesh_file (str) – path to the mesh file containing the facets of the boundary
model_name (str) – name of the model (default: model_GENE3D)
Note
By default, when imposing a Neumann boundary condition such that the imposed traction \(\mathbf T\) is given by
\[\mathbf T = \boldsymbol \sigma \mathbf n\]with the full stress tensor
\[\boldsymbol \sigma = \boldsymbol \tau - p \boldsymbol I \]it is necessary to provide at least a traction vector capable to maintain the fluid (the rocks) inside the physical domain i.e. to provide the part of the pressure related to the density structure and the gravitational field. For this purpose, pTatin3d computes
\[\nabla \cdot \nabla p_p = \nabla \cdot (\rho \mathbf g) \]where \(\rho\) is the density, \(\mathbf g\) is the gravitational acceleration vector, and \(p_p\) is refered as the Poisson pressure.
If nothing more is provided, the Neumann boundary condition will be imposed as:
\[\mathbf T = -p_p \mathbf n\]as \(\mathbf n\) points outward the domain. It is possible to add a scalar function (expression) \(\tau(\mathbf x,p_p,t)\) with the syntax
x,y,z,p,tfor the textual variable names (any standard c math function can be used in the expression, see this link). In this case, the Neumann boundary condition will be imposed as:\[\mathbf T = (\tau - p_p) \mathbf n\]Attributes
- tag: int
Tag of the boundary condition
- prefix: str
Prefix: “bc_neumann” for the options
- bc_type: int
Type of the boundary condition in the model. For Neumann: 1
- bc_name: str
Name of the boundary condition in the model, name is arbitrary but providing one is mandatory
- mesh_file: str
Path to the mesh file containing the facets of the boundary
- dev_stress: str
Expression for the deviatoric stress. Can be None, in that case no deviatoric stress is imposed, only the pressure.
Methods
- sprint_option(self)
generates the string to be written in the options file for the Neumann boundary condition.
- Returns:
string to be written in the options file
- Return type:
str
Energy boundary conditions
- class genepy.TemperatureBC(conditions: dict, model_name: str = 'model_GENE3D')
- class TemperatureBC(conditions: dict, model_name: str = 'model_GENE3D')
Class to generate the options for pTatin3d thermal energy boundary condition.
- Parameters:
conditions (dict) – dictionary of the form
{face: value}wherefaceis one of['xmin','xmax','ymin','ymax','zmin','zmax']andvalueis the temperature value.model_name (str) – name of the model (default: model_GENE3D)