1#ifndef EXASEIS_REFINEMENT_HEADER
2#define EXASEIS_REFINEMENT_HEADER
9 template <
class Shortcuts>
21 template <
class Shortcuts>
24 trackVelocity(
int a_basisSize,
double a_refine_threshold,
double a_coarsen_threshold):
39 double maxVelocity_2 = 0;
40 double minVelocity_2 = std::numeric_limits<double>::max();
44 double velocity_2 = luh[idx(i, j, k, s.v + 0)] * luh[idx(i, j, k, s.v + 0)]
45 + luh[idx(i, j, k, s.v + 1)] * luh[idx(i, j, k, s.v + 1)]
46 + luh[idx(i, j, k, s.v + 2)] * luh[idx(i, j, k, s.v + 2)];
48 maxVelocity_2 = std::max(maxVelocity_2, velocity_2);
49 minVelocity_2 = std::min(minVelocity_2, velocity_2);
75 template <
class Shortcuts>
95 template <
class Shortcuts>
116 double left_vertex[3];
117 double right_vertex[3];
118 bool elementBetweenPoints =
true;
120 for (
int i = 0; i < Dimensions; i++) {
121 left_vertex[i] = center[i] - dx[i] * 0.5;
122 right_vertex[i] = center[i] + dx[i] * 0.5;
126 if (elementBetweenPoints) {
138 template <
class Shortcuts>
148 FL =
new double[a_basisSize];
149 std::copy_n(a_FL, a_basisSize,
FL);
160 double left_vertex = std::numeric_limits<double>::min();
169 vertex += luh[idx(i, j, k, s.curve_grid +
top)] *
FL[i];
170 }
else if (
top == 1) {
171 vertex += luh[idx(j, i, k, s.curve_grid +
top)] *
FL[i];
172 }
else if (
top == 0) {
173 vertex += luh[idx(j, k, i, s.curve_grid +
top)] *
FL[i];
176 left_vertex = std::max(left_vertex, vertex);
180 bool elementAbovePointSource = (left_vertex <
position[
top]);
181 if (elementAbovePointSource) {
196 template <
class Shortcuts>
216 double left_vertex[Dimensions];
217 for (
int d = 0; d < Dimensions; d++) {
218 left_vertex[d] = center[d] - dx[d] * 0.5;
221 bool elementAbovePointSource = (left_vertex[
top] <
position[
top]);
222 if (elementAbovePointSource) {
236 template <
class Shortcuts>
245 FR =
new double[a_basisSize];
246 std::copy_n(a_FR, a_basisSize,
FR);
248 FL =
new double[a_basisSize];
249 std::copy_n(a_FL, a_basisSize,
FL);
260 double left_vertex[3];
261 double right_vertex[3];
263 bool positionInElement =
true;
266 left_vertex[0] += luh[idx(0, 0, i, s.curve_grid + 0)] *
FL[i];
269 left_vertex[1] += luh[idx(0, i, 0, s.curve_grid + 1)] *
FL[i];
272 left_vertex[2] += luh[idx(i, 0, 0, s.curve_grid + 2)] *
FL[i];
276 for (
int i = 0; i < Dimensions; i++) {
277 positionInElement &= ((left_vertex[i] <=
position[i]) && (right_vertex[i] >=
position[i]));
280 if (positionInElement) {
294 template <
class Shortcuts>
311 double left_vertex[3];
312 double right_vertex[3];
314 bool positionInElement =
true;
316 for (
int i = 0; i < Dimensions; i++) {
317 left_vertex[i] = center[i] - dx[i] * 0.5;
318 right_vertex[i] = center[i] + dx[i] * 0.5;
321 for (
int i = 0; i < Dimensions; i++) {
322 positionInElement &= ((left_vertex[i] <=
position[i]) && (right_vertex[i] >=
position[i]));
325 if (positionInElement) {
328 std::cout <<
"refine ps" << std::endl;
337 template <
class Shortcuts>
353 int a_coarsest_level,
354 double a_coarsest_size,
356 const double domainSize[3],
357 const double domainOffset[3]
370 double coarse_layer[3];
377 coarse_layer[
left] = 12.5 / 25.0;
378 coarse_layer[
top] = 12.5 / 25.0;
379 coarse_layer[
front] = 12.5 / 25.0;
381 double coarse_elts[3];
389 coarse_layer[
left] = std::floor(coarse_elts[
left] * coarse_layer[
left]) / coarse_elts[
left];
390 coarse_layer[
top] = std::floor(coarse_elts[
top] * coarse_layer[
top]) / coarse_elts[
top];
391 coarse_layer[
front] = std::floor(coarse_elts[
front] * coarse_layer[
front]) / coarse_elts[
front];
405 for (
int depth = 0; depth <
max_depth; depth++) {
408 num_elts[
left] = coarse_elts[
left] * pow(3.0, depth);
409 num_elts[
top] = coarse_elts[
top] * pow(3.0, depth);
410 num_elts[
front] = coarse_elts[
front] * pow(3.0, depth);
413 int num_layer_elements[3];
414 num_layer_elements[
left] = coarse_layer[
left] * num_elts[
left];
415 num_layer_elements[
top] = coarse_layer[
top] * num_elts[
top];
419 for (
int d = 0; d < depth; d++) {
420 num_layer_elements[
left] += std::pow(3.0, d);
421 num_layer_elements[
top] += std::pow(3.0, d);
422 num_layer_elements[
front] += std::pow(3.0, d);
426 double threshold_width[3];
427 threshold_width[0] = domainSize[
left] / num_elts[
left] * num_layer_elements[
left];
428 threshold_width[1] = domainSize[
front] / num_elts[
front] * num_layer_elements[
front];
429 threshold_width[2] = domainSize[
top] / num_elts[
top] * num_layer_elements[
top];
438 threshold_p[2][depth] = domainOffset[
top] + domainSize[
top] - threshold_width[2];
462 if (cellInBoundaryLayer) {
471 template <
class Shortcuts>
475 for (
int i = 0; i < Dimensions; i++) {
489 bool inRadius =
true;
490 for (
int i = 0; i < Dimensions; i++) {
508 template <
class Shortcuts>
511 RefineFilterCube(
double a_left_vertice[3],
double a_right_vertice[3],
int a_level_inside,
int a_level_outside):
514 for (
int i = 0; i < Dimensions; i++) {
528 bool left_vertice_in =
true;
529 bool right_vertice_in =
true;
530 for (
int i = 0; i < Dimensions; i++) {
535 right_vertice_in &= center[i] + dx[i] >
left_vertice[i];
538 if (left_vertice_in || right_vertice_in) {
std::vector< double > threshold_m[2]
std::vector< double > threshold_p[3]
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)
CoarseBoundaryLayer(int a_max_depth, int a_coarsest_level, double a_coarsest_size, int a_top, const double domainSize[3], const double domainOffset[3])
double rectangle_right[3]
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine) override
RefineBetweenPositions(double a_left[3], double a_right[3])
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)
RefineCubeAroundPosition(double a_position[3], double radius)
RefineDownToPositionCustomCoordinates(int a_basisSize, int level, double a_position[3], int a_top, double *a_FL)
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)
RefineDownToPosition(int a_basisSize, int level, double a_position[3], int a_top)
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)
RefineFilterCube(double a_left_vertice[3], double a_right_vertice[3], int a_level_inside, int a_level_outside)
RefinePositionCustomCoordinates(double a_position[3], int a_basisSize, double *a_FL, double *a_FR)
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)
RefinePosition(double a_position[3])
virtual bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine)=0
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine) override
double coarsen_threshold_2
bool eval(const double *luh, const tarch::la::Vector< Dimensions, double > ¢er, const tarch::la::Vector< Dimensions, double > &dx, double t, const int level, ::exahype2::RefinementCommand &refine) override
double refine_threshold_2
trackVelocity(int a_basisSize, double a_refine_threshold, double a_coarsen_threshold)
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.