8 def __init__(self, unknowns, auxiliary_variables, dimensions):
12 self.
Q = sympy.symarray(
"Q", (unknowns + auxiliary_variables))
13 self.
delta_Q = sympy.symarray(
"deltaQ", (unknowns + auxiliary_variables))
16 self.
x = sympy.symarray(
"x", (dimensions))
17 self.
h = sympy.symarray(
"h", (dimensions))
22 Returns identifier for the unknowns.
23 Use this one to feed set_plot_description of your solver.
29 result += str(self.
Q[i])
33 self, is_cell_mapping=True, is_boundary=False, has_delta=False
36 Return the C code that maps the quantities from Q onto
37 properly labelled quantities
41 result +=
"[[maybe_unused]] const "
43 result += sympy.printing.cxxcode(self.
Q[i])
45 result +=
" = Qinside[" + str(i) +
"];\n"
46 result +=
"nonCriticalAssertion(Qinside[" + str(i) +
"] == Qinside[" + str(i) +
"]);\n"
48 result +=
" = Q[" + str(i) +
"];\n"
49 result +=
"nonCriticalAssertion(Q[" + str(i) +
"] == Q[" + str(i) +
"]);\n"
50 result +=
"assertion(!std::isnan(" + sympy.printing.cxxcode(self.
Q[i]) +
"));\n"
54 result +=
"nonCriticalAssertion(deltaQ[" + str(i) +
"] == deltaQ[" + str(i) +
"]);\n"
55 result +=
"[[maybe_unused]] const "
57 result += sympy.printing.cxxcode(self.
delta_Q[i])
58 result +=
" = deltaQ[" + str(i) +
"];\n"
59 result +=
"assertion(!std::isnan(" + sympy.printing.cxxcode(self.
delta_Q[i]) +
"));\n"
62 result +=
"const double x_"
66 result +=
"volumeCentre"
68 result +=
"faceCentre"
69 result +=
"(" + str(i) +
");\n"
71 result +=
"const double h_"
75 result +=
"(" + str(i) +
");\n"
81 Q covers both unknowns plus auxiliary variables. They simply are concatenated.
82 So if you have 10 unknowns and 2 auxiliary variables, the name you assign the
83 10s Q entry is the one for the first auxiliary variable.
84 There's also a dedicated routine for auxiliary variables if you prefer this one.
85 @see name_auxiliary_variable
87 self.
Q[offset_in_Q] = sympy.symbols(name)
88 return self.
Q[offset_in_Q]
91 self.
Q[number + self.
unknowns] = sympy.symbols(name)
95 new_entry = sympy.symarray(name, cardinality)
96 for i
in range(0, cardinality):
97 self.
Q[offset_in_Q + i] = new_entry[i]
101 if isinstance(Q, numpy.ndarray):
102 offset_in_delta_Q = numpy.where(self.
Q == Q[0])[0][0]
104 name = Q[0].name.split(
"_")[0]
105 new_entry = sympy.symarray(
"delta_" + name, cardinality)
106 for i
in range(0, cardinality):
107 self.
delta_Q[offset_in_delta_Q + i] = new_entry[i]
110 offset_in_delta_Q = numpy.where(self.
Q == Q)[0][0]
113 self.
delta_Q[offset_in_delta_Q] = sympy.symbols(
"delta_" + name)
114 return self.
delta_Q[offset_in_delta_Q]
117 result =
"assertion(normal >= 0);\n"
118 result +=
"//assertion(normal < Dimensions);\n"
120 result +=
"assertion(!std::isnan(Qoutside[" + str(i) +
"]));\n"
121 result +=
"assertion(!std::isnan(Qinside[" + str(i) +
"]));\n"
122 result +=
"nonCriticalAssertion(Qinside[" + str(i) +
"] == Qinside[" + str(i) +
"]);\n"
123 result +=
"Qoutside[" + str(i) +
"] = Qinside[" + str(i) +
"];\n"
124 result +=
"nonCriticalAssertion(Qoutside[" + str(i) +
"] == Qoutside[" + str(i) +
"]);\n"
129 invoke_evalf_before_output: boolean
130 If your expression is a symbolic expression (default) then we use evalf
131 before we pipe it into the output. If your expression is something numeric,
132 then evalf will fail (as it is not defined for scalar quantities).
134 result =
"assertion(normal >= 0);\n"
135 result +=
"//assertion(normal < Dimensions);\n"
137 is_cell_mapping=
False, is_boundary=
True
140 if invoke_evalf_before_output:
141 result += sympy.printing.cxxcode(
157 invoke_evalf_before_output: boolean
158 If your expression is a symbolic expression (default) then we use evalf
159 before we pipe it into the output. If your expression is something numeric,
160 then evalf will fail (as it is not defined for scalar quantities).
166 if invoke_evalf_before_output:
167 result += sympy.printing.cxxcode(
179 result +=
"assertion(!std::isnan(Q[" + str(i) +
"]));\n"
name_Q_entries(self, offset_in_Q, cardinality, name)
__init__(self, unknowns, auxiliary_variables, dimensions)
_implementation_of_mapping_onto_named_quantities(self, is_cell_mapping=True, is_boundary=False, has_delta=False)
Return the C code that maps the quantities from Q onto properly labelled quantities.
implementation_of_boundary_conditions(self, invoke_evalf_before_output=False)
invoke_evalf_before_output: boolean If your expression is a symbolic expression (default) then we use...
unknown_identifier_for_plotter(self)
Returns identifier for the unknowns.
implementation_of_initial_conditions(self, invoke_evalf_before_output=False)
invoke_evalf_before_output: boolean If your expression is a symbolic expression (default) then we use...
implementation_of_homogeneous_Neumann_BC(self)
name_auxiliary_variable(self, number, name)
name_Q_entry(self, offset_in_Q, name)
Q covers both unknowns plus auxiliary variables.