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

#153: Provide Tpetra version of CDR_Model #120

Merged

Conversation

JacobDomagala
Copy link
Collaborator

@JacobDomagala JacobDomagala commented Aug 17, 2023

Fixes #119 Fixes #153

thearusable
thearusable previously approved these changes Aug 30, 2023
@JacobDomagala
Copy link
Collaborator Author

Thanks @cwschilly for the comments. This PR is still in development, I've pushed the changes because I'm working on two separate machines and I want to keep the code in sync, it's not yet ready.

@JacobDomagala JacobDomagala force-pushed the 119-provide-tpetra-version-of-Tempus_HHTAlphaTest branch 2 times, most recently from 492b5a7 to 8776bf4 Compare September 20, 2023 21:42
@JacobDomagala JacobDomagala changed the title #119: Remove Epetra dependency from Tempus_HHTAlpha #119: Provide Tpetra version of CDR_Model Sep 20, 2023
@JacobDomagala JacobDomagala changed the title #119: Provide Tpetra version of CDR_Model #153: Provide Tpetra version of CDR_Model Sep 20, 2023
@JacobDomagala JacobDomagala marked this pull request as draft September 20, 2023 21:52
@JacobDomagala JacobDomagala force-pushed the 119-provide-tpetra-version-of-Tempus_HHTAlphaTest branch from d1ecd54 to efa30d1 Compare September 20, 2023 21:59
@github-actions
Copy link

github-actions bot commented Sep 20, 2023

⚡ Code quality check ⚡


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

void CDR_Test(const Comm& comm, const int commSize, Teuchos::FancyOStream &out, bool& success){
RCP<Tempus::IntegratorBasic<double> > integrator;
std::vector<RCP<Thyra::VectorBase<double>>> solutions;
std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
std::vector<double> StepSize;

!Line: 331 - warning: function 'CDR_Test' has cognitive complexity of 26 (threshold 25) [readability-function-cognitive-complexity]
!Line: 400 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 400 - note: +1
!Line: 447 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 349 - note: inferred assignment of ID-dependent value from ID-dependent variable model_pl [altera-id-dependent-backward-branch]
!Line: 349 - note: inferred assignment of ID-dependent value from ID-dependent variable model_pl [altera-id-dependent-backward-branch]

TEUCHOS_UNIT_TEST(BackwardEuler, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 472 - warning: initialization of 'instance_BackwardEuler_CDR_UnitTest' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
!Line: 472 - note: possibly throwing constructor declared here

TEUCHOS_UNIT_TEST(BackwardEuler, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 472 - warning: variable 'instance_BackwardEuler_CDR_UnitTest' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

TEUCHOS_UNIT_TEST(BackwardEuler, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 472 - warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]

TEUCHOS_UNIT_TEST(BackwardEuler, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 472 - warning: static objects are disallowed; if possible, use a constexpr constructor instead [fuchsia-statically-constructed-objects]

TEUCHOS_UNIT_TEST(BackwardEuler, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 487 - warning: initialization of 'instance_BackwardEuler_CDR_Tpetra_UnitTest' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
!Line: 487 - note: possibly throwing constructor declared here

TEUCHOS_UNIT_TEST(BackwardEuler, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 487 - warning: variable 'instance_BackwardEuler_CDR_Tpetra_UnitTest' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

TEUCHOS_UNIT_TEST(BackwardEuler, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 487 - warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]

TEUCHOS_UNIT_TEST(BackwardEuler, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 487 - warning: static objects are disallowed; if possible, use a constexpr constructor instead [fuchsia-statically-constructed-objects]

void CDR_Test(const Comm& comm, const int commSize, Teuchos::FancyOStream &out, bool& success){
RCP<Tempus::IntegratorBasic<double> > integrator;
std::vector<RCP<Thyra::VectorBase<double>>> solutions;
std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
std::vector<double> StepSize;

!Line: 480 - warning: function 'CDR_Test' has cognitive complexity of 35 (threshold 25) [readability-function-cognitive-complexity]
!Line: 555 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 555 - note: +1
!Line: 605 - note: +1, including nesting penalty of 0, nesting level increased to 1

auto pl = sublist(pList, "Tempus", true);
auto dt = pl->sublist("Demo Integrator").sublist("Time Step Control").get<double>("Initial Time Step");
dt *= 2.0;
auto model_pl = sublist(pList, "CDR Model", true);
const auto nTimeStepSizes = model_pl->get<int>("Number of Time Step Sizes", 5);

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

auto dt = pl->sublist("Demo Integrator").sublist("Time Step Control").get<double>("Initial Time Step");
dt *= 2.0;
auto model_pl = sublist(pList, "CDR Model", true);
const auto nTimeStepSizes = model_pl->get<int>("Number of Time Step Sizes", 5);

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

const auto dx = std::fabs(left_end-right_end) /
static_cast<double>(num_elements);
auto solutionHistory =
integrator->getSolutionHistory();
int nStates = solutionHistory->getNumStates();
for (int i=0; i<nStates; i++) {

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

auto x = solutionState->getX();
auto ttime = solutionState->getTime();
ftmp << "ZONE T=\"Time="<<ttime<<"\", I="
<<num_elements+1<<", F=BLOCK\n";
for (int j = 0; j < num_elements+1; j++) {
const auto x_coord = left_end + static_cast<double>(j) * dx;

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

const auto& x = *(solutions[solutions.size()-1]);
std::ofstream ftmp("Tempus_BDF2_CDR-Solution.dat");
for (int n = 0; n < num_elements+1; n++) {
const auto dx = std::fabs(left_end-right_end) /
static_cast<double>(num_elements);

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

const auto dx = std::fabs(left_end-right_end) /
static_cast<double>(num_elements);
const auto x_coord = left_end + static_cast<double>(n) * dx;
ftmp << x_coord << " " << Thyra::get_ele(x,n) << std::endl;
}
ftmp.close();

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

TEUCHOS_UNIT_TEST(BDF2, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 629 - warning: initialization of 'instance_BDF2_CDR_UnitTest' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
!Line: 629 - note: possibly throwing constructor declared here

TEUCHOS_UNIT_TEST(BDF2, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 629 - warning: variable 'instance_BDF2_CDR_UnitTest' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

TEUCHOS_UNIT_TEST(BDF2, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 629 - warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]

TEUCHOS_UNIT_TEST(BDF2, CDR)
{
// Create a communicator for Epetra objects
RCP<Epetra_Comm> comm;
#ifdef Tempus_ENABLE_MPI
comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

!Line: 629 - warning: static objects are disallowed; if possible, use a constexpr constructor instead [fuchsia-statically-constructed-objects]

TEUCHOS_UNIT_TEST(BDF2, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 644 - warning: initialization of 'instance_BDF2_CDR_Tpetra_UnitTest' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
!Line: 644 - note: possibly throwing constructor declared here

TEUCHOS_UNIT_TEST(BDF2, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 644 - warning: variable 'instance_BDF2_CDR_Tpetra_UnitTest' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

TEUCHOS_UNIT_TEST(BDF2, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 644 - warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]

TEUCHOS_UNIT_TEST(BDF2, CDR_Tpetra)
{
// Get default Tpetra template types
using SC = Tpetra::Vector<>::scalar_type;
using LO = Tpetra::Vector<>::local_ordinal_type;
using GO = Tpetra::Vector<>::global_ordinal_type;

!Line: 644 - warning: static objects are disallowed; if possible, use a constexpr constructor instead [fuchsia-statically-constructed-objects]


@JacobDomagala JacobDomagala force-pushed the 119-provide-tpetra-version-of-Tempus_HHTAlphaTest branch 2 times, most recently from a61bd1c to a4b2fed Compare September 28, 2023 13:45
@JacobDomagala JacobDomagala marked this pull request as ready for review September 28, 2023 13:48
@JacobDomagala
Copy link
Collaborator Author

@stmcgovern @cwschilly Ok I think it's ready to be reviewed

Copy link
Collaborator

@cwschilly cwschilly left a comment

Choose a reason for hiding this comment

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

LGTM

@JacobDomagala
Copy link
Collaborator Author

I'll have to rebase the commits, one of them is not signed

@JacobDomagala JacobDomagala force-pushed the 119-provide-tpetra-version-of-Tempus_HHTAlphaTest branch from a4b2fed to fb45636 Compare September 28, 2023 14:53
@stmcgovern stmcgovern merged commit 09dcf6d into NGA-FY23-develop Sep 28, 2023
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants