Skip to content

#197: NOX: Provide Tpetra versions of LOCA_TestProblems tests #199

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

Draft
wants to merge 13 commits into
base: NGA-FY23-develop
Choose a base branch
from

Conversation

antoinemeyer5
Copy link

WIP, fixes #197

@antoinemeyer5 antoinemeyer5 added the wontfix This will not be worked on label Sep 20, 2023
@cwschilly cwschilly removed the wontfix This will not be worked on label Sep 27, 2023
@tlamonthezie tlamonthezie self-assigned this Sep 29, 2023
@tlamonthezie
Copy link

tlamonthezie commented Sep 29, 2023

WIP State

LOCA_TestProblems is a Test library providing a set of classes that are used by LOCA_UnitTests (and maybe in other tests)

The work is in in the following state:

  • Translated classes : Basis
  • WIP classes: FiniteElementProblem, Pitchfork_FiniteElementProblem, (LOCALinearConstraint)

We added also a NGA_DevTests to LOCA_UnitTests to test the library classes during the development of the tpetra versions of LOCA_TestProblems classes

@github-actions
Copy link

⚡ Code quality check ⚡

🔴 cppcheck found 4 issues! Click here to see details.

void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts

!Line: 66 - performance: Function parameter 'x' should be passed by const reference. [passedByValue]

void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts

!Line: 66 - performance: Function parameter 'u' should be passed by const reference. [passedByValue]

void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts

!Line: 66 - style: The function 'getBasis' is never used. [unusedFunction]

#include "Basis.H"
#include "NOX_Common.H"
// Constructor - creates the Tpetra objects (maps and vectors)
template <typename ScalarType>
Pitchfork_FiniteElementProblem::Pitchfork_FiniteElementProblem(

!Line: 55 - information: Include file: "Basis.H" not found. [missingInclude]


🔴 clang-tidy found 21 issues! Click here to see details.

phi(2),
dphide(2),
uu(0.0),
xx(0.0),
duu(0.0),
eta(0.0),

!Line: 55 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

dphide(2),
uu(0.0),
xx(0.0),
duu(0.0),
eta(0.0),
wt(0.0),

!Line: 56 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts

!Line: 66 - warning: parameter name 'gp' is too short, expected at least 3 characters [readability-identifier-length]

void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts

!Line: 66 - warning: 2 adjacent parameters of 'getBasis' of similar type ('std::vector<double>') are easily swapped by mistake [bugprone-easily-swappable-parameters]
!Line: 66 - note: the first parameter in the range is 'x'
!Line: 66 - note: the last parameter in the range is 'u'

void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts

!Line: 66 - warning: parameter name 'x' is too short, expected at least 3 characters [readability-identifier-length]

void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts

!Line: 66 - warning: parameter name 'u' is too short, expected at least 3 characters [readability-identifier-length]

int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts
phi[0]=(1.0-eta)/2.0;

!Line: 67 - warning: variable 'N' of type 'int' can be declared 'const' [misc-const-correctness]

int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts
phi[0]=(1.0-eta)/2.0;

!Line: 67 - warning: variable name 'N' is too short, expected at least 3 characters [readability-identifier-length]

if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts
phi[0]=(1.0-eta)/2.0;
phi[1]=(1.0+eta)/2.0;

!Line: 68 - warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}
// Calculate basis function and derivatives at nodel pts
phi[0]=(1.0-eta)/2.0;
phi[1]=(1.0+eta)/2.0;
dphide[0]=-0.5;

!Line: 69 - warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

phi[0]=(1.0-eta)/2.0;
phi[1]=(1.0+eta)/2.0;
dphide[0]=-0.5;
dphide[1]=0.5;
// Caculate basis function and derivative at GP.

!Line: 72 - warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

phi[1]=(1.0+eta)/2.0;
dphide[0]=-0.5;
dphide[1]=0.5;
// Caculate basis function and derivative at GP.
dx=0.5*(x[1]-x[0]);

!Line: 73 - warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

dphide[0]=-0.5;
dphide[1]=0.5;
// Caculate basis function and derivative at GP.
dx=0.5*(x[1]-x[0]);
xx=0.0;

!Line: 74 - warning: 0.5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

dphide[1]=0.5;
// Caculate basis function and derivative at GP.
dx=0.5*(x[1]-x[0]);
xx=0.0;
uu=0.0;

!Line: 75 - warning: 0.5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

dx=0.5*(x[1]-x[0]);
xx=0.0;
uu=0.0;
duu=0.0;
for (int i=0; i < N; i++) {
xx += x[i] * phi[i];

!Line: 78 - warning: 0.5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

for (int i=0; i < N; i++) {
xx += x[i] * phi[i];
uu += u[i] * phi[i];
duu += u[i] * dphide[i];
}

!Line: 82 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

!Line: 88 - warning: redundant return statement at the end of a function with a void return type [readability-redundant-control-flow]

Teuchos::GlobalMPISession mpiSession(&argc, &argv);
auto comm = Tpetra::getDefaultComm();
const int myRank = comm->getRank();
// test Pitchfork_FiniteElementProblem (inheriting FiniteElementProblem)
int numGlobalElements = 1000;

!Line: 18 - warning: variable 'mpiSession' of type 'Teuchos::GlobalMPISession' can be declared 'const' [misc-const-correctness]

Teuchos::GlobalMPISession mpiSession(&argc, &argv);
auto comm = Tpetra::getDefaultComm();
const int myRank = comm->getRank();
// test Pitchfork_FiniteElementProblem (inheriting FiniteElementProblem)
int numGlobalElements = 1000;

!Line: 18 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

int numGlobalElements = 1000;
auto feProblem = Pitchfork_FiniteElementProblem<ST>(numGlobalElements, comm);
if (myRank == 0) {
std::cout << "End Result: TEST PASSED" << std::endl;
}

!Line: 23 - warning: variable 'numGlobalElements' of type 'int' can be declared 'const' [misc-const-correctness]

int numGlobalElements = 1000;
auto feProblem = Pitchfork_FiniteElementProblem<ST>(numGlobalElements, comm);
if (myRank == 0) {
std::cout << "End Result: TEST PASSED" << std::endl;
}

!Line: 23 - warning: 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]


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

Successfully merging this pull request may close these issues.

NOX: Provide Tpetra versions of LOCA_TestProblems tests
3 participants