Skip to content

Commit

Permalink
Merge Pull Request #13312 from cgcgcg/Trilinos/fixWarnings
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: b'MueLu, Panzer, TrilinosCouplings, Pamgen: Fix warnings'
PR Author: cgcgcg
  • Loading branch information
trilinos-autotester authored Aug 3, 2024
2 parents 808a38b + 389e058 commit fd2e038
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ void ReitzingerPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::BuildP(Level
ArrayView<const SC> values_E, values_N;

size_t Ne = EdgeMatrix->getLocalNumRows();
size_t Nn = NodeMatrix->getLocalNumRows();

// Notinal upper bound on local number of coarse edges
size_t max_edges = PnT_D0T->getLocalNumEntries();
Expand Down Expand Up @@ -262,7 +261,7 @@ void ReitzingerPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::BuildP(Level
}

// Exponential memory reallocation, if needed
if (current + 1 >= max_edges) {
if (current + 1 >= Teuchos::as<LocalOrdinal>(max_edges)) {
max_edges *= 2;
D0_colind.resize(max_edges);
D0_values.resize(max_edges);
Expand Down
2 changes: 1 addition & 1 deletion packages/pamgen/test/rtc_test/rtcompiler-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ int main( int argc, char* argv[] )
realProgram(arrayOneReal, arrayTwoReal, plainValOneReal,
plainValTwoReal, plainValThreeReal, testChar);

const double epsilon = 1.0e-15;
[[maybe_unused]] const double epsilon = 1.0e-15;

for (int i = 0; i < 9; ++i) {
assert ( fabs(arrayOne[i] - arrayOneReal[i]) < epsilon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,6 @@ namespace panzer {
Teuchos::FancyOStream& out,
bool &success) {
using Scalar = double;
using LocalOrdinal = int;
using GlobalOrdinal = panzer::GlobalOrdinal;
using ThyLinOp = Thyra::TpetraLinearOp<Scalar,LocalOrdinal,GlobalOrdinal>;
using CrsMatrix = Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal>;
using Operator = Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal>;
Expand Down
6 changes: 1 addition & 5 deletions packages/panzer/disc-fe/src/Panzer_Interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ Teuchos::RCP<Thyra::LinearOpBase<double>> buildInterpolation(const Teuchos::RCP<
using Teuchos::rcp_dynamic_cast;

using Scalar = double;
using LocalOrdinal = int;
using GlobalOrdinal = panzer::GlobalOrdinal;

using tpetraBlockedLinObjFactory = typename panzer::BlockedTpetraLinearObjFactory<panzer::Traits, Scalar, LocalOrdinal, GlobalOrdinal>;
#ifdef PANZER_HAVE_EPETRA_STACK
Expand Down Expand Up @@ -159,8 +157,6 @@ Teuchos::RCP<Thyra::LinearOpBase<double> > buildInterpolation(const Teuchos::RCP
using Teuchos::rcp_dynamic_cast;

using Scalar = double;
using LocalOrdinal = int;
using GlobalOrdinal = panzer::GlobalOrdinal;

using STS = Teuchos::ScalarTraits<Scalar>;
using KAT = Kokkos::ArithTraits<Scalar>;
Expand Down Expand Up @@ -561,7 +557,7 @@ Teuchos::RCP<Thyra::LinearOpBase<double> > buildInterpolation(const Teuchos::RCP
{
// Check that there is no entry yet or that we are overwriting it with the same value
auto row = lcl_tp_interp_matrix.rowConst(range_row);
for(size_t kk = 0; kk<row.length; ++kk)
for(LocalOrdinal kk = 0; kk<row.length; ++kk)
if (row.colidx(kk) == domainLIDs_d(domainOffsets_d(domainIter)))
if (!(KAT::magnitude(row.value(kk)-val) < entryFilterTol || KAT::magnitude(row.value(kk)) < entryFilterTol)) {
#ifdef PANZER_INTERPOLATION_DEBUG_OUTPUT
Expand Down
54 changes: 27 additions & 27 deletions packages/panzer/dof-mgr/src/Panzer_GlobalIndexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ConnManager;

class GlobalIndexer {
public:
//! Pure virtual destructor: prevents warnings with inline empty implementation
//! Pure virtual destructor: prevents warnings with inline empty implementation
virtual ~GlobalIndexer() {}

/** Get communicator associated with this global indexer.
Expand Down Expand Up @@ -60,19 +60,19 @@ class GlobalIndexer {
/** \brief Reverse lookup of the field string from
* a field number.
*
* \param[in] num Field number. Assumed to be
* \param[in] num Field number. Assumed to be
* a valid field number. Computed
* from <code>getFieldNum</code>.
*
* \returns Field name.
* \returns Field name.
*/
virtual const std::string & getFieldString(int num) const = 0;

/** What are the blockIds included in this connection manager?
*/
virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const = 0;
virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const = 0;

/** Is the specified field in the element block?
/** Is the specified field in the element block?
*/
virtual bool fieldInBlock(const std::string & field, const std::string & block) const = 0;

Expand All @@ -97,7 +97,7 @@ class GlobalIndexer {
* \param[in] subcellDim
* \param[in] subcellId
*/
virtual const std::pair<std::vector<int>,std::vector<int> > &
virtual const std::pair<std::vector<int>,std::vector<int> > &
getGIDFieldOffsets_closure(const std::string & blockId, int fieldNum,
int subcellDim,int subcellId) const = 0;

Expand Down Expand Up @@ -152,9 +152,9 @@ class GlobalIndexer {
*/
virtual void
getOwnedAndGhostedIndices(std::vector<panzer::GlobalOrdinal>& indices) const = 0;

/// @name Epetra related functions. NOTE: for use with Epetra only! Will be deprecated when we drop epetra support!
///@{
///@{

/** \brief Get the global IDs for a particular element. This function
* overwrites the <code>gids</code> variable.
Expand Down Expand Up @@ -228,7 +228,7 @@ class GlobalIndexer {

/** Access the local IDs for an element. The local ordering is according to
* the <code>getOwnedAndGhostedIndices</code> method. Note
*
*
* @param cellIds [in] The list of cells we require LIDs for
* @param lids [in/out] View to fill with LIDs. extent(1) MUST be sized correctly if num_dofs is not provided.
* @param num_dofs [in] (optional) Number of DOFs in the current element block.
Expand All @@ -244,7 +244,7 @@ class GlobalIndexer {
*/
template <typename ArrayT>
void getElementLIDs(PHX::View<const int*> cellIds, ArrayT lids, const int num_dofs = 0) const
{
{
CopyCellLIDsFunctor<ArrayT> functor;
functor.cellIds = cellIds;
functor.global_lids = localIDs_k_;
Expand All @@ -255,8 +255,8 @@ class GlobalIndexer {
functor.num_dofs = lids.extent(1);

#ifdef PANZER_DEBUG
TEUCHOS_ASSERT(functor.local_lids.extent(1) >= num_dofs);
TEUCHOS_ASSERT(functor.global_lids.extent(1) >= num_dofs);
TEUCHOS_ASSERT(static_cast<int>(functor.local_lids.extent(1)) >= num_dofs);
TEUCHOS_ASSERT(static_cast<int>(functor.global_lids.extent(1)) >= num_dofs);
#endif

Kokkos::parallel_for(cellIds.extent(0),functor);
Expand Down Expand Up @@ -286,47 +286,47 @@ class GlobalIndexer {
KOKKOS_INLINE_FUNCTION
void operator()(const int cell) const
{
for(int i=0;i<num_dofs;i++)
for(int i=0;i<num_dofs;i++)
local_lids(cell,i) = global_lids(cellIds(cell),i);
}

};

protected:

/** This method is used by derived classes to the construct the local IDs from
/** This method is used by derived classes to the construct the local IDs from
* the <code>getOwnedAndGhostedIndices</code> method.
*/
void buildLocalIds()
{
{
// this method is implmented as two steps to ensure
// that setLocalIds works, it would be better to simply
// call:
// buildLocalIdsFromOwnedElements(localIDs_);
// buildLocalIdsFromOwnedElements(localIDs_);

std::vector<std::vector<panzer::LocalOrdinal> > localIDs;
buildLocalIdsFromOwnedElements(localIDs);
std::vector<std::vector<panzer::LocalOrdinal> > localIDs;
buildLocalIdsFromOwnedElements(localIDs);
setLocalIds(localIDs);
}

/** This method is used by derived classes to the construct the local IDs from
/** This method is used by derived classes to the construct the local IDs from
* the <code>getOwnedAndGhostedIndices</code> method.
*/
void buildLocalIdsFromOwnedElements(std::vector<std::vector<panzer::LocalOrdinal> > & localIDs) const ;
void buildLocalIdsFromOwnedElements(std::vector<std::vector<panzer::LocalOrdinal> > & localIDs) const ;

/** This method provides some capability to set the local IDs externally without
* using the default buildLocalIds. The point is that we want to keep "getElementLIDs"
* access exteremly fast.
*/
void setLocalIds(const std::vector<std::vector<panzer::LocalOrdinal> > & localIDs)
{
{
// determine the maximium second dimension of the local IDs
std::size_t max = 0;
for(std::size_t i=0;i<localIDs.size();i++)
max = localIDs[i].size() > max ? localIDs[i].size() : max;

// allocate for the kokkos size
Kokkos::View<panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device> localIDs_k
Kokkos::View<panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device> localIDs_k
= Kokkos::View<panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device>("ugi:localIDs_",localIDs.size(),max);
auto localIDs_h = Kokkos::create_mirror_view(localIDs_k);
for(std::size_t i=0;i<localIDs.size();i++) {
Expand Down Expand Up @@ -358,15 +358,15 @@ buildLocalIdsFromOwnedElements(std::vector<std::vector<panzer::LocalOrdinal> > &
{
std::vector<panzer::GlobalOrdinal> ownedAndGhosted;
this->getOwnedAndGhostedIndices(ownedAndGhosted);

// build global to local hash map (temporary and used only once)
std::unordered_map<panzer::GlobalOrdinal,panzer::LocalOrdinal> hashMap;
for(std::size_t i=0;i<ownedAndGhosted.size();i++)
hashMap[ownedAndGhosted[i]] = i;

std::vector<std::string> elementBlocks;
this->getElementBlockIds(elementBlocks);

// compute total number of elements
std::size_t numElmts = 0;
for(std::size_t eb=0;eb<elementBlocks.size();eb++)
Expand All @@ -382,11 +382,11 @@ buildLocalIdsFromOwnedElements(std::vector<std::vector<panzer::LocalOrdinal> > &
this->getElementGIDs(elmts[e],gids,elementBlocks[eb]);
std::vector<panzer::LocalOrdinal> & lids = localIDs[elmts[e]];
lids.resize(gids.size());

for(std::size_t g=0;g<gids.size();g++)
lids[g] = hashMap[gids[g]];
}
}
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ TEUCHOS_UNIT_TEST(tCartesianDOFMgr_DynRankView, threed)
#endif

int np = comm.getSize(); // number of processors
int rank = comm.getRank(); // processor rank

// mesh description
panzer::GlobalOrdinal nx = 10, ny = 7, nz = 4;
Expand Down Expand Up @@ -108,21 +107,13 @@ TEUCHOS_UNIT_TEST(tCartesianDOFMgr_DynRankView, threed)
dofManager->addField("eblock-0_1_0","UY",pattern_U);
dofManager->addField("eblock-0_1_0","UZ",pattern_U);

// int temp_num = dofManager->getFieldNum("TEMPERATURE");
int ux_num = dofManager->getFieldNum("UX");
int uy_num = dofManager->getFieldNum("UY");
// int uz_num = dofManager->getFieldNum("UZ");
// int p_num = dofManager->getFieldNum("PRESSURE");
// int b_num = dofManager->getFieldNum("B");
// int e_num = dofManager->getFieldNum("E");

// build global unknowns (useful comment!)
dofManager->buildGlobalUnknowns();
// print out some diagnostic information

// print out some diagnostic information
///////////////////////////////////////////////////////////

dofManager->printFieldInformation(out);
dofManager->printFieldInformation(out);

out << std::endl << "Load balancing: " << printUGILoadBalancingInformation(*dofManager) << std::endl;

Expand Down Expand Up @@ -154,7 +145,7 @@ TEUCHOS_UNIT_TEST(tCartesianDOFMgr_DynRankView, threed)
TEST_EQUALITY(hostOffsetsStdVector[i],hostKokkosOffsets(i));
}
}

}

} // namespace panzer::unit test
Loading

0 comments on commit fd2e038

Please sign in to comment.