Skip to content

Commit

Permalink
Merge 'trilinos/Trilinos:develop' (353c286) into 'tcad-charon/Trilino…
Browse files Browse the repository at this point in the history
…s:develop' (5498f28).

* trilinos-develop:
  zoltan2:  made method names in test consistent with actual method names; (trilinos#9268)
  Fix Panzer's tests with UVM off (trilinos#9599)
  MueLu: add doc, remove commented code, formatting
  • Loading branch information
Charonops Jenkins Pipeline committed Aug 24, 2021
2 parents 5498f28 + 353c286 commit 5ef4b4e
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
// ***********************************************************************
//
// @HEADER
/*
* MueLu_BlockedGaussSeidelSmoother_decl.hpp
*
* Created on: 30.01.2012
* Author: tobias
*/

#ifndef MUELU_BLOCKEDGAUSSSEIDELSMOOTHER_DECL_HPP_
#define MUELU_BLOCKEDGAUSSSEIDELSMOOTHER_DECL_HPP_
Expand Down Expand Up @@ -90,10 +84,10 @@ namespace MueLu {
\code
// prototypes for direct solvers for blocks 1 and 2
RCP<SmootherPrototype> smoProto11 = rcp( new DirectSolver("", Teuchos::ParameterList(), A11Fact) );
RCP<SmootherPrototype> smoProto22 = rcp( new DirectSolver("", Teuchos::ParameterList(), A22Fact) );
RCP<SmootherFactory> Smoo11Fact = rcp( new SmootherFactory(smoProto11) );
RCP<SmootherFactory> Smoo22Fact = rcp( new SmootherFactory(smoProto22) );
RCP<SmootherPrototype> smoProto11 = rcp(new DirectSolver("", Teuchos::ParameterList(), A11Fact));
RCP<SmootherPrototype> smoProto22 = rcp(new DirectSolver("", Teuchos::ParameterList(), A22Fact));
RCP<SmootherFactory> Smoo11Fact = rcp(new SmootherFactory(smoProto11));
RCP<SmootherFactory> Smoo22Fact = rcp(new SmootherFactory(smoProto22));
// define factory manager objects for sublocks
RCP<FactoryManager> M11 = rcp(new FactoryManager());
Expand All @@ -105,10 +99,10 @@ namespace MueLu {
M22->SetFactory("Smoother", Smoo22Fact);
// create blocked Gauss-Seidel smoother for 2x2 blocked matrix
RCP<BlockedGaussSeidelSmoother> smootherPrototype = rcp( new BlockedGaussSeidelSmoother(2,1.0) );
RCP<BlockedGaussSeidelSmoother> smootherPrototype = rcp(new BlockedGaussSeidelSmoother(2,1.0));
smootherPrototype->AddFactoryManager(M11);
smootherPrototype->AddFactoryManager(M22);
RCP<SmootherFactory> smootherFact = rcp( new SmootherFactory(smootherPrototype) );
RCP<SmootherFactory> smootherFact = rcp( new SmootherFactory(smootherPrototype) );
// use smootherFact in main-factory manager
\endcode
Expand Down Expand Up @@ -181,8 +175,11 @@ namespace MueLu {
//! Return a simple one-line description of this object.
std::string description() const;

//! Print the object with some verbosity level to an FancyOStream object.
//using MueLu::Describable::describe; // overloading, not hiding
/*! \brief Print the object with some verbosity level \c verbLevel to an FancyOStream object \c out
*
* - use MueLu::Describable::describe;
* - overloading, not hiding
*/
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const;

//! Get a rough estimate of cost per iteration
Expand All @@ -207,11 +204,14 @@ namespace MueLu {
//! A Factory
RCP<FactoryBase> AFact_;

//! block operator
RCP<Matrix> A_; // < ! internal blocked operator "A" generated by AFact_
//! internal blocked operator "A" generated by AFact_
RCP<Matrix> A_;

RCP<const MapExtractorClass> rangeMapExtractor_; //!< range map extractor (from A_ generated by AFact)
RCP<const MapExtractorClass> domainMapExtractor_; //!< domain map extractor (from A_ generated by AFact)
//! range map extractor (from A_ generated by AFact)
RCP<const MapExtractorClass> rangeMapExtractor_;

//! domain map extractor (from A_ generated by AFact)
RCP<const MapExtractorClass> domainMapExtractor_;
}; // class Amesos2Smoother

} // namespace MueLu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
// ***********************************************************************
//
// @HEADER
/*
* MueLu_BlockedGaussSeidelSmoother_def.hpp
*
* Created on: 30.01.2012
* Author: tobias
*/

#ifndef MUELU_BLOCKEDGAUSSSEIDELSMOOTHER_DEF_HPP_
#define MUELU_BLOCKEDGAUSSSEIDELSMOOTHER_DEF_HPP_
Expand Down Expand Up @@ -102,10 +96,10 @@ namespace MueLu {
size_t myPos = Teuchos::as<size_t>(pos);

if (myPos < FactManager_.size()) {
// replace existing entris in FactManager_ vector
// replace existing entries in FactManager_ vector
FactManager_.at(myPos) = FactManager;
} else if( myPos == FactManager_.size()) {
// add new Factory manager in the end of the vector
} else if(myPos == FactManager_.size()) {
// append new Factory manager at the end of the vector
FactManager_.push_back(FactManager);
} else { // if(myPos > FactManager_.size())
RCP<Teuchos::FancyOStream> out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
Expand Down Expand Up @@ -133,13 +127,10 @@ namespace MueLu {
// request "A" for current subblock row (only needed for Thyra mode)
currentLevel.DeclareInput("A",(*it)->GetFactory("A").get());
}

//RCP<Teuchos::FancyOStream> out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
}

template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
void BlockedGaussSeidelSmoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Setup(Level &currentLevel) {
//typedef Xpetra::BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> BlockedCrsOMatrix;

RCP<Teuchos::FancyOStream> out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));

Expand Down Expand Up @@ -202,8 +193,6 @@ namespace MueLu {
//this->GetOStream(Runtime1) << "BlockedGaussSeidel: X is a MultiVector of size " << X.getMap()->getGlobalNumElements() << std::endl;
//TEUCHOS_TEST_FOR_EXCEPTION(bA->getFullDomainMap()->isSameAs(*(X.getMap())) == false, Exceptions::RuntimeError, "MueLu::BlockedGaussSeidelSmoother::Apply(): The map of the solution vector X is not the same as domain map of the blocked operator A. Please check the map of X and A.");
}


#endif
SC zero = Teuchos::ScalarTraits<SC>::zero(), one = Teuchos::ScalarTraits<SC>::one();

Expand Down Expand Up @@ -377,11 +366,7 @@ namespace MueLu {
// FIXME: This is a placeholder
return Teuchos::OrdinalTraits<size_t>::invalid();
}



} // namespace MueLu



#endif /* MUELU_BLOCKEDGAUSSSEIDELSMOOTHER_DEF_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace panzer {
auto worksets = wkstContainer->getWorksets(workset_descriptor);

TEST_ASSERT(worksets->size()==1);

auto & workset = (*worksets)[0];

auto rot_matrices = workset.getIntegrationValues(sid).surface_rotation_matrices;
Expand All @@ -146,15 +146,15 @@ namespace panzer {
const int num_real_cells = num_owned_cells + num_ghost_cells;
const int num_virtual_cells = workset.numVirtualCells();
const int num_cells = num_real_cells + num_virtual_cells;

const int faces_per_cell = 6; // hexahedron
auto & face_connectivity = workset.getFaceConnectivity();

// sanity check on cell counts: should have 6 virtual, 1 owned
TEST_EQUALITY(num_owned_cells, 1);
TEST_EQUALITY(num_ghost_cells, 0);
TEST_EQUALITY(num_virtual_cells, 6);

TEST_ASSERT(rot_matrices.rank()==4);
TEST_ASSERT(rot_matrices.extent_int(0)==num_cells);
TEST_ASSERT(rot_matrices.extent_int(2)==3);
Expand All @@ -174,22 +174,26 @@ namespace panzer {
// the rotation matrices for the other faces of the virtual cell should be all 0s.
const bool is_virtual = (c >= num_real_cells);
int virtual_local_face_id = -1; // the virtual cell face that adjoins the real cell

if (is_virtual)
{
// determine which face adjoins the real cell:
int face_ordinal = -1;
for (int local_face_id=0; local_face_id<faces_per_cell; local_face_id++)
{
face_ordinal = face_connectivity.subcellForCell(c, local_face_id);
face_ordinal = face_connectivity.subcellForCellHost(c, local_face_id);
if (face_ordinal >= 0)
{
virtual_local_face_id = local_face_id;
break;
}
}
}


auto rot_matrices_view = PHX::as_view(rot_matrices);
auto rot_matrices_h = Kokkos::create_mirror_view(rot_matrices_view);
Kokkos::deep_copy(rot_matrices_h, rot_matrices_view);

for(int p=0;p<num_points;p++) {
const int local_face_ordinal = p / points_per_face;
bool expect_rotation_matrix = true; // if false, we expect all 0s
Expand All @@ -198,34 +202,34 @@ namespace panzer {
expect_rotation_matrix = (local_face_ordinal == virtual_local_face_id);
}
out << "Cell,Point = " << c << "," << p << std::endl;
out << " " << rot_matrices(c,p,0,0) << " " << rot_matrices(c,p,0,1) << " " << rot_matrices(c,p,0,2) << std::endl;
out << " " << rot_matrices(c,p,1,0) << " " << rot_matrices(c,p,1,1) << " " << rot_matrices(c,p,1,2) << std::endl;
out << " " << rot_matrices(c,p,2,0) << " " << rot_matrices(c,p,2,1) << " " << rot_matrices(c,p,2,2) << std::endl;
out << " " << rot_matrices_h(c,p,0,0) << " " << rot_matrices_h(c,p,0,1) << " " << rot_matrices_h(c,p,0,2) << std::endl;
out << " " << rot_matrices_h(c,p,1,0) << " " << rot_matrices_h(c,p,1,1) << " " << rot_matrices_h(c,p,1,2) << std::endl;
out << " " << rot_matrices_h(c,p,2,0) << " " << rot_matrices_h(c,p,2,1) << " " << rot_matrices_h(c,p,2,2) << std::endl;
out << std::endl;

if (expect_rotation_matrix)
{
// mutually orthogonal
TEST_ASSERT(std::fabs(rot_matrices(c,p,0,0) * rot_matrices(c,p,1,0) +
rot_matrices(c,p,0,1) * rot_matrices(c,p,1,1) +
rot_matrices(c,p,0,2) * rot_matrices(c,p,1,2))<=1e-14);
TEST_ASSERT(std::fabs(rot_matrices(c,p,0,0) * rot_matrices(c,p,2,0) +
rot_matrices(c,p,0,1) * rot_matrices(c,p,2,1) +
rot_matrices(c,p,0,2) * rot_matrices(c,p,2,2))<=1e-14);
TEST_ASSERT(std::fabs(rot_matrices(c,p,1,0) * rot_matrices(c,p,2,0) +
rot_matrices(c,p,1,1) * rot_matrices(c,p,2,1) +
rot_matrices(c,p,1,2) * rot_matrices(c,p,2,2))<=1e-14);
TEST_ASSERT(std::fabs(rot_matrices_h(c,p,0,0) * rot_matrices_h(c,p,1,0) +
rot_matrices_h(c,p,0,1) * rot_matrices_h(c,p,1,1) +
rot_matrices_h(c,p,0,2) * rot_matrices_h(c,p,1,2))<=1e-14);
TEST_ASSERT(std::fabs(rot_matrices_h(c,p,0,0) * rot_matrices_h(c,p,2,0) +
rot_matrices_h(c,p,0,1) * rot_matrices_h(c,p,2,1) +
rot_matrices_h(c,p,0,2) * rot_matrices_h(c,p,2,2))<=1e-14);
TEST_ASSERT(std::fabs(rot_matrices_h(c,p,1,0) * rot_matrices_h(c,p,2,0) +
rot_matrices_h(c,p,1,1) * rot_matrices_h(c,p,2,1) +
rot_matrices_h(c,p,1,2) * rot_matrices_h(c,p,2,2))<=1e-14);

// normalized
TEST_FLOATING_EQUALITY(std::sqrt(rot_matrices(c,p,0,0) * rot_matrices(c,p,0,0) +
rot_matrices(c,p,0,1) * rot_matrices(c,p,0,1) +
rot_matrices(c,p,0,2) * rot_matrices(c,p,0,2)),1.0,1e-14);
TEST_FLOATING_EQUALITY(std::sqrt(rot_matrices(c,p,1,0) * rot_matrices(c,p,1,0) +
rot_matrices(c,p,1,1) * rot_matrices(c,p,1,1) +
rot_matrices(c,p,1,2) * rot_matrices(c,p,1,2)),1.0,1e-14);
TEST_FLOATING_EQUALITY(std::sqrt(rot_matrices(c,p,2,0) * rot_matrices(c,p,2,0) +
rot_matrices(c,p,2,1) * rot_matrices(c,p,2,1) +
rot_matrices(c,p,2,2) * rot_matrices(c,p,2,2)),1.0,1e-14);
TEST_FLOATING_EQUALITY(std::sqrt(rot_matrices_h(c,p,0,0) * rot_matrices_h(c,p,0,0) +
rot_matrices_h(c,p,0,1) * rot_matrices_h(c,p,0,1) +
rot_matrices_h(c,p,0,2) * rot_matrices_h(c,p,0,2)),1.0,1e-14);
TEST_FLOATING_EQUALITY(std::sqrt(rot_matrices_h(c,p,1,0) * rot_matrices_h(c,p,1,0) +
rot_matrices_h(c,p,1,1) * rot_matrices_h(c,p,1,1) +
rot_matrices_h(c,p,1,2) * rot_matrices_h(c,p,1,2)),1.0,1e-14);
TEST_FLOATING_EQUALITY(std::sqrt(rot_matrices_h(c,p,2,0) * rot_matrices_h(c,p,2,0) +
rot_matrices_h(c,p,2,1) * rot_matrices_h(c,p,2,1) +
rot_matrices_h(c,p,2,2) * rot_matrices_h(c,p,2,2)),1.0,1e-14);
}
else
{
Expand All @@ -235,7 +239,7 @@ namespace panzer {
for (int j=0; j<3; j++)
{
// since these should be filled in as exact machine 0s, we do non-floating comparison
TEST_EQUALITY(rot_matrices(c,p,i,j), 0.0);
TEST_EQUALITY(rot_matrices_h(c,p,i,j), 0.0);
}
}
}
Expand Down
Loading

0 comments on commit 5ef4b4e

Please sign in to comment.