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).data() + BasisElementsPerFace2,
68 fineGridFaces{{UNKNOWN_IDENTIFIER}}Estimates(d).data() + BasisElementsPerFace,
69 proj, toPoints, fromPoints, ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}}));
71 fineGridFaces""" + solver_name +
"""Estimates(d+DIMENSIONS).data(),
72 fineGridFaces{{UNKNOWN_IDENTIFIER}}Estimates(d + DIMENSIONS).data(),
73 proj, toPoints, fromPoints, ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}}));
75 // Projected flux estimations
77 fineGridFaces""" + solver_name +
"""FluxEstimates(d).data() + FluxElementsPerFace2,
78 fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d).data() + FluxElementsPerFace,
79 proj, toPoints, fromPoints, {{NUMBER_OF_UNKNOWNS}});
81 fineGridFaces""" + solver_name +
"""FluxEstimates(d+DIMENSIONS).data(),
82 fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d + DIMENSIONS).data(),
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 // 1 if right side, 0 if left
109 //const int ownFaceSide = marker.getSelectedFaceNumber() > DIMENSIONS;
110 const int ownFaceSide = fineGridFace{{SOLVER_NAME}}FaceLabel.getUpdated(0) ? 0 : 1;
112 // Make sure that I have indeed been updated, as if the split is between spacetrees it is possible
113 // neither side has been updated
114 if( fineGridFace{{SOLVER_NAME}}FaceLabel.getUpdated(ownFaceSide) ){
115 // Projected solution estimations
117 fineGridFace{{UNKNOWN_IDENTIFIER}}Estimates.data() + ownFaceSide * BasisElementsPerFace,
118 BasisElementsPerFace,
119 fineGridFace""" + solver_name +
"""QEstimates.data() + ownFaceSide * BasisElementsPerFace
121 // Projected flux estimations
123 fineGridFace{{UNKNOWN_IDENTIFIER}}FluxEstimates.data() + ownFaceSide * FluxElementsPerFace,
125 fineGridFace""" + solver_name +
"""QFluxEstimates.data() + ownFaceSide * FluxElementsPerFace
135#include "peano4/utils/Loop.h"
137template<typename pTo, typename pFrom>
138inline void dg2dgFace(pTo* Qto, const pFrom* Qfrom, const double* proj, int toPoints, int fromPoints, int numVars){
141 const int toSize = toPoints*toPoints*numVars;
143 const int toSize = toPoints*numVars;
146 std::fill_n(Qto, toSize, 0.0);
148 //For each point we project to
149 dfore(dofTo, toPoints, DIMENSIONS-1, 0) {
150 const int dofToSerialised = dofTo[0]
152 + dofTo[1] * toPoints
156 //Compute the contribution from each contributing point
157 dfore(dofFrom, fromPoints, DIMENSIONS-1, 0) {
158 const int dofFromSerialised = dofFrom[0]
160 + dofFrom[1] * fromPoints
164 for(int var=0; var<numVars; var++){
165 Qto[dofToSerialised*numVars+var] += Qfrom[dofFromSerialised*numVars+var] * proj[dofTo[0]*fromPoints+dofFrom[0]]
167 * proj[dofTo[1]*fromPoints+dofFrom[1]]
178 s1_load_cell = solver._load_cell_data_default_guard() + cond
179 s1_store_cell = solver._store_cell_data_default_guard() + cond
180 s1_provide_cell = solver._provide_cell_data_to_compute_kernels_default_guard() + cond
182 solver._load_cell_data_default_guard =
lambda : s1_load_cell
183 solver._store_cell_data_default_guard =
lambda : s1_store_cell
184 solver._provide_cell_data_to_compute_kernels_default_guard =
lambda : s1_provide_cell
187 s1_load_face = solver._load_face_data_default_guard() + cond
188 s1_store_face = solver._store_face_data_default_guard() + cond
189 s1_provide_face = solver._provide_face_data_to_compute_kernels_default_guard() + cond
191 solver._load_face_data_default_guard =
lambda : s1_load_face
192 solver._store_face_data_default_guard =
lambda : s1_store_face
193 solver._provide_face_data_to_compute_kernels_default_guard =
lambda : s1_provide_face
195 solver.set_implementation()
197 solver._rhs_estimates_projection.generator.send_condition += cond
198 solver._rhs_estimates_projection.generator.receive_and_merge_condition += cond
199 solver._flux_estimates_projection.generator.send_condition += cond
200 solver._flux_estimates_projection.generator.receive_and_merge_condition += cond
210def fuseADERSolvers(solver1, solver2, cond_1, cond_2):
212 solver_1_cond =
" and " + cond_1
213 solver_2_cond =
" and " + cond_2
262 compute_time_step_size =
"""
263 double timeStepSize = std::min( repositories::""" + solver1.get_name_of_global_instance() +
""".getAdmissibleTimeStepSize(),
264 repositories::""" + solver2.get_name_of_global_instance() +
""".getAdmissibleTimeStepSize());
267 solver1._compute_time_step_size = compute_time_step_size
268 solver2._compute_time_step_size = compute_time_step_size
270 aderSolver1QuadPoints = solver1._basis.quadrature_points(render=
False)
271 aderSolver2QuadPoints = solver2._basis.quadrature_points(render=
False)
273 if(aderSolver1QuadPoints!=aderSolver2QuadPoints):
281 if not os.path.exists(
"observers"):
283 os.makedirs(
"observers")
285 raise Exception(
"Path /observers could not be created")
286 f = open(
"observers/dg2dgface.h",
"w")
290 solver1.add_user_solver_includes(
"""\n#include "observers/dg2dgface.h"\n""")
291 solver2.add_user_solver_includes(
"""\n#include "observers/dg2dgface.h"\n""")
same_basis_postprocessing_kernel(condition, solver_name)
different_basis_postprocessing_kernel(condition, order, proj, solver_name)
updateSolverStorage(solver, cond)
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...