6 Transforms the degrees of freedom located at Lagrange quadrature_points to degrees of freedom
7 located at a set of points as defined by the parameter points.
9 Let us denote by P the projection operator. The DoF are computed according to:
11 u@x = sum_{m} P_m u^DG_m
15 The corresponding degrees of freedom located at the set of points defined by the parameter x.
17 proj = [[mp.mpf(0)
for _
in range(len(quad_points_from))]
for _
in range(len(quad_points_to))]
18 for idx, point
in enumerate(quad_points_to):
20 n = len(quad_points_from)
28 numerator *= (point - quad_points_from[k])
29 denominator *= (quad_points_from[i] - quad_points_from[k])
30 result*= numerator / denominator
35 return ', '.join([mp.nstr(x, n=12)
for xs
in xss
for x
in xs])
40 repositories::{{SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
41 and not marker.willBeRefined() and not marker.hasBeenRefined()
45 constexpr int fromPoints = {{ORDER}} + 1;
46 constexpr int toPoints = """ + str(order) +
""" + 1;
49 constexpr int SpaceFaceSize = fromPoints;
50 constexpr int SpaceFaceSize2 = toPoints;
52 constexpr int SpaceFaceSize = fromPoints*fromPoints;
53 constexpr int SpaceFaceSize2 = toPoints*toPoints;
56 constexpr int FluxElementsPerFace = SpaceFaceSize * {{NUMBER_OF_UNKNOWNS}};
57 constexpr int BasisElementsPerFace = SpaceFaceSize * ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}});
59 constexpr int FluxElementsPerFace2 = SpaceFaceSize2 * {{NUMBER_OF_UNKNOWNS}};
60 constexpr int BasisElementsPerFace2 = SpaceFaceSize2 * ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}});
62 constexpr double proj[toPoints*fromPoints] = {""" + proj +
"""};
64 for (int d = 0; d < DIMENSIONS; d++) {
65 // Projected solution estimations
67 fineGridFaces""" + solver_name +
"""Estimates(d).value + BasisElementsPerFace2,
68 fineGridFaces{{UNKNOWN_IDENTIFIER}}Estimates(d).value + BasisElementsPerFace,
69 proj, toPoints, fromPoints, ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}}));
71 fineGridFaces""" + solver_name +
"""Estimates(d+DIMENSIONS).value,
72 fineGridFaces{{UNKNOWN_IDENTIFIER}}Estimates(d + DIMENSIONS).value,
73 proj, toPoints, fromPoints, ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}}));
75 // Projected flux estimations
77 fineGridFaces""" + solver_name +
"""FluxEstimates(d).value + FluxElementsPerFace2,
78 fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d).value + FluxElementsPerFace,
79 proj, toPoints, fromPoints, {{NUMBER_OF_UNKNOWNS}});
81 fineGridFaces""" + solver_name +
"""FluxEstimates(d+DIMENSIONS).value,
82 fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d + DIMENSIONS).value,
83 proj, toPoints, fromPoints, {{NUMBER_OF_UNKNOWNS}});
92 repositories::{{SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
93 and not marker.willBeRefined() and not marker.hasBeenRefined()
97 constexpr int fromPoints = {{ORDER}} + 1;
100 constexpr int SpaceFaceSize = fromPoints;
102 constexpr int SpaceFaceSize = fromPoints*fromPoints;
105 constexpr int FluxElementsPerFace = SpaceFaceSize * {{NUMBER_OF_UNKNOWNS}};
106 constexpr int BasisElementsPerFace = SpaceFaceSize * ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}});
108 for (int d = 0; d < DIMENSIONS; d++) {
109 // Projected solution estimations
111 fineGridFaces{{UNKNOWN_IDENTIFIER}}Estimates(d).value + BasisElementsPerFace,
112 BasisElementsPerFace,
113 fineGridFaces""" + solver_name +
"""Estimates(d).value + BasisElementsPerFace
116 fineGridFaces{{UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value,
117 BasisElementsPerFace,
118 fineGridFaces""" + solver_name +
"""Estimates(d+DIMENSIONS).value
121 // Projected flux estimations
123 fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d).value + FluxElementsPerFace,
125 fineGridFaces""" + solver_name +
"""FluxEstimates(d).value + FluxElementsPerFace
128 fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d + DIMENSIONS).value,
130 fineGridFaces""" + solver_name +
"""FluxEstimates(d+DIMENSIONS).value
140#include "peano4/utils/Loop.h"
142template<typename pTo, typename pFrom>
143inline void dg2dgFace(pTo* Qto, const pFrom* Qfrom, const double* proj, int toPoints, int fromPoints, int numVars){
146 const int toSize = toPoints*toPoints*numVars;
148 const int toSize = toPoints*numVars;
151 std::fill_n(Qto, toSize, 0.0);
153 //For each point we project to
154 dfore(dofTo, toPoints, DIMENSIONS-1, 0) {
155 const int dofToSerialised = dofTo[0]
157 + dofTo[1] * toPoints
161 //Compute the contribution from each contributing point
162 dfore(dofFrom, fromPoints, DIMENSIONS-1, 0) {
163 const int dofFromSerialised = dofFrom[0]
165 + dofFrom[1] * fromPoints
169 for(int var=0; var<numVars; var++){
170 Qto[dofToSerialised*numVars+var] += Qfrom[dofFromSerialised*numVars+var] * proj[dofTo[0]*fromPoints+dofFrom[0]]
172 * proj[dofTo[1]*fromPoints+dofFrom[1]]
193 solver_1_cond =
" and " + cond_1
194 solver_2_cond =
" and " + cond_2
196 s1 = solver1._load_cell_data_default_guard() + solver_1_cond
197 s12 = solver1._store_cell_data_default_guard() + solver_1_cond
198 s13 = solver1._provide_cell_data_to_compute_kernels_default_guard() + solver_1_cond
209 solver1._load_cell_data_default_guard = s1_guard
210 solver1._store_cell_data_default_guard = s12_guard
211 solver1._provide_cell_data_to_compute_kernels_default_guard = s13_guard
213 s2 = solver2._load_cell_data_default_guard() + solver_2_cond
214 s21 = solver2._store_cell_data_default_guard() + solver_2_cond
215 s23 = solver2._provide_cell_data_to_compute_kernels_default_guard() + solver_2_cond
226 solver2._load_cell_data_default_guard = s2_guard
227 solver2._store_cell_data_default_guard = s21_guard
228 solver2._provide_cell_data_to_compute_kernels_default_guard = s23_guard
230 solver1.set_implementation()
231 solver2.set_implementation()
253 compute_time_step_size =
"""
254 double timeStepSize = std::min( repositories::""" + solver1.get_name_of_global_instance() +
""".getAdmissibleTimeStepSize(),
255 repositories::""" + solver2.get_name_of_global_instance() +
""".getAdmissibleTimeStepSize());
258 solver1._compute_time_step_size = compute_time_step_size
259 solver2._compute_time_step_size = compute_time_step_size
261 aderSolver1QuadPoints = solver1._basis.quadrature_points(render=
False)
262 aderSolver2QuadPoints = solver2._basis.quadrature_points(render=
False)
264 if(aderSolver1QuadPoints!=aderSolver2QuadPoints):
272 if not os.path.exists(
"observers"):
274 os.makedirs(
"observers")
276 raise Exception(
"Path /observers could not be created")
277 f = open(
"observers/dg2dgface.h",
"w")
281 solver1.add_user_solver_includes(
"""\n#include "observers/dg2dgface.h"\n""")
282 solver2.add_user_solver_includes(
"""\n#include "observers/dg2dgface.h"\n""")
285 solver1._action_set_postprocess_solution._compute_kernel +=
same_basis_postprocessing_kernel(solver_1_cond, str(solver2._order), solver2._unknown_identifier())
286 solver2._action_set_postprocess_solution._compute_kernel +=
same_basis_postprocessing_kernel(solver_2_cond, str(solver1._order), solver1._unknown_identifier())
different_basis_postprocessing_kernel(condition, order, proj, solver_name)
compute_projector_to_point_set(quad_points_from, quad_points_to)
Transforms the degrees of freedom located at Lagrange quadrature_points to degrees of freedom located...
same_basis_postprocessing_kernel(condition, order, solver_name)