Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

33 prolongation and restriction tests #34

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

CodingAllan
Copy link
Member

@CodingAllan CodingAllan commented Jul 6, 2023

Merge Request - GuideLine Checklist

Guideline to check code before resolve WIP and approval, respectively.
As many checkboxes as possible should be ticked.

Checks by code author:

Always to be checked:

  • There is at least one issue associated with the pull request.
  • New code adheres with the coding guidelines
  • No large data files have been added to the repository. Maximum size for files should be of the order of KB not MB. In particular avoid adding of pdf, word, or other files that cannot be change-tracked correctly by git.

If functions were changed or functionality was added:

  • Tests for new functionality has been added
  • A local test was succesful

If new functionality was added:

  • There is appropriate documentation of your work. (use doxygen style comments)

If new third party software is used:

  • Did you pay attention to its license? Please remember to add it to the wiki after successful merging.

If new mathematical methods or epidemiological terms are used:

  • Are new methods referenced? Did you provide further documentation?

  • The following questions are addressed in the documentation (if need be):
    ** Developers (what did you do?, how can it be maintained?)
    ** For users (how to use your work?)
    ** For admins (how to install and configure your work?)

  • For documentation: Please write or update the Readme in the current working directory!

Checks by code reviewer(s):

  • Is the code clean of development artifacts e.g., unnecessary comments, prints, ...
  • The ticket goals for each associated issue are reached or problems are clearly addressed (i.e., a new issue was introduced).
  • There are appropriate unit tests and they pass.
  • The git history is clean and linearized for the merge request. All reviewers should squash commits and write a simple and meaningful commit message.
  • Coverage report for new code is acceptable.
  • No large data files have been added to the repository. Maximum size for files should be of the order of KB not MB. In particular avoid adding of pdf, word, or other files that cannot be change-tracked correctly by git.

@CodingAllan CodingAllan linked an issue Jul 6, 2023 that may be closed by this pull request
Copy link
Member

@mknaranja mknaranja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @CodingAllan, I had a brief look. Generally this looks quite complete but there are some things that could be addressed before a more detailed review. Could you add some comments and also look at what I annotated elsewise?

gyro::icntl[Param::verbose] = 0;
gyro::icntl[Param::debug] = 0;
gyro::icntl[Param::extrapolation] = 0;
gyro::icntl[Param::DirBC_Interior] = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should test with and without Dirichlet conditions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do this, but should the boundary conditions affect the operator ?
I thought that if we prolongate a solution u, then the information on boundary conditions should be stored in the stiffness matrix and right-hand side not neccessarily in the prolongation and restriction operator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No they shouldnt. And it should be ensured that we have the same operator.

gyro::icntl[Param::verbose] = 0;
gyro::icntl[Param::debug] = 0;
gyro::icntl[Param::extrapolation] = 0;
gyro::icntl[Param::DirBC_Interior] = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should test with and without Dirichlet conditions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally (and in contrast) to my comment about "why do you set it if you don't use it?", we should maybe check with parameters that could make a change as in a future version, these might be implemented here. In particular Dirichlet boundary conditions could lead to a simplification but the operator should still handle both cases correctly. However, some parameters are probably never used in the context of the prolongation (also applies to other functions below)

tests/test_restriction.cpp Outdated Show resolved Hide resolved
tests/test_prolongation.cpp Outdated Show resolved Hide resolved
tests/test_restriction.cpp Outdated Show resolved Hide resolved
tests/test_restriction.cpp Outdated Show resolved Hide resolved
tests/test_prolongation.cpp Outdated Show resolved Hide resolved
tests/test_prolongation.cpp Outdated Show resolved Hide resolved
…undary condition. Removed parameters not needed for the test. Soon I will consider to mock functions creating the grid.
… the same ansatz does not work.Look into it next week
@codecov
Copy link

codecov bot commented Sep 1, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@25cd29f). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage        ?   35.91%           
=======================================
  Files           ?       86           
  Lines           ?     7028           
  Branches        ?        0           
=======================================
  Hits            ?     2524           
  Misses          ?     4504           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CodingAllan
Copy link
Member Author

Hi @mknaranja , I just wanted to ask if I should add more comments to the program. Aside from that I think that this is ready for review!

#include "gmgpolar.h"

#ifndef MOCKGRID_H
#define MOCKGRID_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define MOCKGRID_H
#define MOCKGRID_H

Comment on lines +8 to +13
for (int i = 0; i < new_level->nr; i++) {
new_level->r[i] = gyro::dcntl[Param::R0] +
i * (gyro::dcntl[Param::R] - gyro::dcntl[Param::R0]) / new_level->nr; //uniform grid
}

new_level->r[new_level->nr] = gyro::dcntl[Param::R];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i = 0; i < new_level->nr; i++) {
new_level->r[i] = gyro::dcntl[Param::R0] +
i * (gyro::dcntl[Param::R] - gyro::dcntl[Param::R0]) / new_level->nr; //uniform grid
}
new_level->r[new_level->nr] = gyro::dcntl[Param::R];
for (int i = 0; i <= new_level->nr; i++) {
new_level->r[i] = gyro::dcntl[Param::R0] +
static_cast<double>(i) * (gyro::dcntl[Param::R] - gyro::dcntl[Param::R0]) / static_cast<double>(new_level->nr); //uniform grid
}

new_level->theta = std::vector<double>(new_level->ntheta);

for (int i = 0; i < new_level->ntheta; i++) {
new_level->theta[i] = 2 * PI * i / ntmp; //uniform in theta
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new_level->theta[i] = 2 * PI * i / ntmp; //uniform in theta
new_level->theta[i] = 2. * PI * static_cast<double>(i) / ntmp; //uniform in theta

EXPECT_EQ(u_test[(j / 2) * ctheta_int + (i / 2)], sol[j * p_level.ntheta_int + i])
<< "coarse node injection is failing";
}
else if (i % 2 != 0 && j % 2 == 0) { // theta_i is fine node
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else if (i % 2 != 0 && j % 2 == 0) { // theta_i is fine node
else if (i % 2 != 0 && j % 2 == 0) {
// as numbering in angle (theta_i) is odd, we have a fine node with
// coarse neighbors at (r_i, theta_j - k_{j-1}) and (r_i, theta_j + k_j)

Please adapt comment as following. theta_i itself cannot be coarse or fine. It is one coordinate of the node.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i and j have to be exchanged

int i1 = (j / 2) * ctheta_int + (i - 1) / 2; //bottom coarse node in theta
int i2 = (i < p_level.ntheta_int - 1) ? i1 + 1 : (j / 2) * ctheta_int; //top coarse node in theta

double val = (k_q * u_test[i1] + k_qm1 * u_test[i2]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss here (stopped here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit tests for prolongation and restriction operators
2 participants