forked from RiccardoRossi/pyKratos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemperature_neumann_face_condition_2d.py
80 lines (57 loc) · 2.59 KB
/
temperature_neumann_face_condition_2d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from __future__ import print_function, absolute_import, division
import math
from pyKratos import *
from numpy import *
from scipy import linalg
def Create(Id, prop, list_of_nodes):
geom = line2d.Line2D(list_of_nodes)
return TemperatureNeumannFaceCondition(Id, prop, geom)
class TemperatureNeumannFaceCondition:
integration_order = 2 # this is like a c "static variable" one for all of the objects of this type
include_dynamics = True
def __init__(self, Id, prop, geometry):
self.Id = Id
self.prop = prop
self.geometry = geometry
def GetDofsPerNode(self):
return 1
def GetScalarValueOnGauss(self, var, N,step=0):
value = 0.0
for i in range(0, self.geometry.GetNumberOfNodes() ):
value += N[i] * self.geometry[i].GetSolutionStepValue(var, step)
return value
def CalculateLocalSystem(self,ProcessInfo):
order = self.integration_order
nnodes = self.geometry.GetNumberOfNodes()
dofs_per_node = self.GetDofsPerNode()
mat_size = nnodes*dofs_per_node
[Ns, derivatives, weights] = self.geometry.ShapeFunctions(order)
number_of_gauss = len(Ns)
RHS = zeros(mat_size) # no external forces so far
LHS = zeros((mat_size,mat_size))
#integrate external forces to the RHS
for gauss in range(0, number_of_gauss):
weight = weights[gauss]
N = Ns[gauss]
#NOTE: external force is given "per unit area"
fext = self.GetScalarValueOnGauss(FACE_HEAT_FLUX,N)
#print(fext)
for i in range(0,nnodes):
RHS[i] += weight*N[i]*fext
return [LHS, RHS]
# this function returns a list with the node and unkowns to be solved for
def GetDofList(self):
unknowns = []
unknowns.append(Dof(self.geometry[0], TEMPERATURE))
unknowns.append(Dof(self.geometry[1], TEMPERATURE))
return unknowns
def EquationId(self):
equation_ids = []
equation_ids.append(self.geometry[0].EquationId(TEMPERATURE))
equation_ids.append(self.geometry[1].EquationId(TEMPERATURE))
return equation_ids
def GetValues(self, step=0):
values = zeros(self.GetDofsPerNode()*self.geometry.GetNumberOfNodes())
values[0] = self.geometry[0].GetSolutionStepValue(TEMPERATURE, step)
values[1] = self.geometry[1].GetSolutionStepValue(TEMPERATURE, step)
return values