Skip to content

Commit

Permalink
Merge Pull Request #10348 from NexGenAnalytics/Trilinos/panzer-make-e…
Browse files Browse the repository at this point in the history
…petra-optional

Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Panzer: Make Epetra optional (partially) for adapter-stk
PR Author: JacobDomagala
  • Loading branch information
trilinos-autotester authored Apr 24, 2022
2 parents b6b25ca + 2de3c65 commit dba5ca3
Show file tree
Hide file tree
Showing 37 changed files with 534 additions and 583 deletions.
9 changes: 6 additions & 3 deletions packages/panzer/adapters-stk/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
IF(PANZER_HAVE_EPETRA)
ADD_SUBDIRECTORY(PoissonExample)
ADD_SUBDIRECTORY(assembly_engine)
ADD_SUBDIRECTORY(PoissonInterfaceExample)
ENDIF(PANZER_HAVE_EPETRA)

ADD_SUBDIRECTORY(square_mesh)
ADD_SUBDIRECTORY(PoissonExample)
ADD_SUBDIRECTORY(CurlLaplacianExample)
ADD_SUBDIRECTORY(MixedCurlLaplacianExample)
ADD_SUBDIRECTORY(MixedPoissonExample)
ADD_SUBDIRECTORY(PoissonInterfaceExample)
ADD_SUBDIRECTORY(PoissonInterfaceTpetra)
ADD_SUBDIRECTORY(assembly_engine)
ADD_SUBDIRECTORY(main_driver)
ADD_SUBDIRECTORY(ModelEvaluator)
19 changes: 15 additions & 4 deletions packages/panzer/adapters-stk/example/CurlLaplacianExample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include "Panzer_AssemblyEngine_TemplateManager.hpp"
#include "Panzer_AssemblyEngine_TemplateBuilder.hpp"
#include "Panzer_LinearObjFactory.hpp"
#include "Panzer_BlockedEpetraLinearObjFactory.hpp"

#include "Panzer_TpetraLinearObjFactory.hpp"
#include "Panzer_DOFManagerFactory.hpp"
#include "Panzer_FieldManagerBuilder.hpp"
Expand All @@ -82,10 +82,11 @@
#include "Panzer_STK_Utilities.hpp"
#include "Panzer_STK_ResponseEvaluatorFactory_SolutionWriter.hpp"

#include "Epetra_MpiComm.h"

#ifdef PANZER_HAVE_EPETRA
#include "Panzer_BlockedEpetraLinearObjFactory.hpp"
#include "EpetraExt_RowMatrixOut.h"
#include "EpetraExt_VectorOut.h"
#endif

#include "BelosPseudoBlockGmresSolMgr.hpp"
#include "BelosTpetraAdapter.hpp"
Expand Down Expand Up @@ -161,7 +162,7 @@ int main(int argc,char * argv[])

Teuchos::GlobalMPISession mpiSession(&argc,&argv);
Kokkos::initialize(argc,argv);
RCP<Epetra_Comm> Comm = Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

Teuchos::RCP<const Teuchos::MpiComm<int> > comm = Teuchos::rcp(new Teuchos::MpiComm<int>(MPI_COMM_WORLD));
Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
out.setOutputToRootOnly(0);
Expand Down Expand Up @@ -200,6 +201,12 @@ int main(int argc,char * argv[])
clp.setOption("basis-order",&basis_order);
clp.setOption("output-filename",&output_filename);

#ifndef PANZER_HAVE_EPETRA
if(!useTpetra) {
throw std::runtime_error("Panzer is built without Epetra! Either use Panzer_ENABLE_Epetra=ON or run this example with `use-tpetra` flag");
}
#endif

// parse commandline argument
Teuchos::CommandLineProcessor::EParseCommandLineReturn r_parse= clp.parse( argc, argv );
if (r_parse == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED) return 0;
Expand Down Expand Up @@ -338,6 +345,7 @@ int main(int argc,char * argv[])

// build the connection manager
if(!useTpetra) {
#ifdef PANZER_HAVE_EPETRA
const Teuchos::RCP<panzer::ConnManager> conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(mesh));

panzer::DOFManagerFactory globalIndexerFactory;
Expand All @@ -347,6 +355,7 @@ int main(int argc,char * argv[])

// construct some linear algebra object, build object to pass to evaluators
linObjFactory = Teuchos::rcp(new panzer::BlockedEpetraLinearObjFactory<panzer::Traits,int>(comm.getConst(),dofManager_int));
#endif // PANZER_HAVE_EPETRA
}
else {
const Teuchos::RCP<panzer::ConnManager> conn_manager
Expand Down Expand Up @@ -603,6 +612,7 @@ int main(int argc,char * argv[])

void solveEpetraSystem(panzer::LinearObjContainer & container)
{
#ifdef PANZER_HAVE_EPETRA
// convert generic linear object container to epetra container
panzer::EpetraLinearObjContainer & ep_container
= Teuchos::dyn_cast<panzer::EpetraLinearObjContainer>(container);
Expand All @@ -629,6 +639,7 @@ void solveEpetraSystem(panzer::LinearObjContainer & container)
// Therefore we have J*e=-J*u which implies e = -u
// thus we will scale the solution vector
ep_container.get_x()->Scale(-1.0);
#endif // PANZER_HAVE_EPETRA
}

void solveTpetraSystem(panzer::LinearObjContainer & container)
Expand Down
23 changes: 18 additions & 5 deletions packages/panzer/adapters-stk/example/MixedPoissonExample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#include "Panzer_AssemblyEngine_TemplateManager.hpp"
#include "Panzer_AssemblyEngine_TemplateBuilder.hpp"
#include "Panzer_LinearObjFactory.hpp"
#include "Panzer_BlockedEpetraLinearObjFactory.hpp"
#include "Panzer_TpetraLinearObjFactory.hpp"
#include "Panzer_DOFManagerFactory.hpp"
#include "Panzer_FieldManagerBuilder.hpp"
Expand All @@ -77,14 +76,18 @@
#include "Panzer_STK_CubeHexMeshFactory.hpp"
#include "Panzer_STK_CubeTetMeshFactory.hpp"
#include "Panzer_STK_SetupUtilities.hpp"
#include "Panzer_STK_Utilities.hpp"

#include "Panzer_STK_ResponseEvaluatorFactory_SolutionWriter.hpp"
#include "Panzer_HierarchicParallelism.hpp"

#ifdef PANZER_HAVE_EPETRA
#include "Panzer_BlockedEpetraLinearObjFactory.hpp"
#include "Epetra_MpiComm.h"

#include "EpetraExt_RowMatrixOut.h"
#include "EpetraExt_VectorOut.h"
#include "Panzer_STK_Utilities.hpp"
#include "AztecOO.h"
#endif

#include "BelosPseudoBlockGmresSolMgr.hpp"
#include "BelosTpetraAdapter.hpp"
Expand All @@ -94,7 +97,7 @@
#include "Example_ClosureModel_Factory_TemplateBuilder.hpp"
#include "Example_EquationSetFactory.hpp"

#include "AztecOO.h"


#include <sstream>

Expand Down Expand Up @@ -129,7 +132,7 @@ int main(int argc,char * argv[])

Teuchos::GlobalMPISession mpiSession(&argc,&argv);
Kokkos::initialize(argc,argv);
RCP<Epetra_Comm> Comm = Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD));
// RCP<Epetra_Comm> Comm = Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD));
Teuchos::RCP<const Teuchos::MpiComm<int> > comm = Teuchos::rcp(new Teuchos::MpiComm<int>(MPI_COMM_WORLD));
Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
out.setOutputToRootOnly(0);
Expand Down Expand Up @@ -171,6 +174,12 @@ int main(int argc,char * argv[])
if (r_parse == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED) return 0;
if (r_parse != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ) return -1;

if(!useTpetra){
#ifndef PANZER_HAVE_EPETRA
throw std::runtime_error("Trying to run Panzer MixedPoisson Test with Epetra, but Epetra is disabled!");
#endif
}

// cuda optimizations
////////////////////////////////////////////////////
// Always use shared memory optimization for residual
Expand Down Expand Up @@ -295,6 +304,7 @@ int main(int argc,char * argv[])

// build the connection manager
if(!useTpetra) {
#ifdef PANZER_HAVE_EPETRA
const Teuchos::RCP<panzer::ConnManager> conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(mesh));

panzer::DOFManagerFactory globalIndexerFactory;
Expand All @@ -304,6 +314,7 @@ int main(int argc,char * argv[])

// construct some linear algebra object, build object to pass to evaluators
linObjFactory = Teuchos::rcp(new panzer::BlockedEpetraLinearObjFactory<panzer::Traits,int>(comm.getConst(),dofManager_int));
#endif
}
else {
const Teuchos::RCP<panzer::ConnManager> conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(mesh));
Expand Down Expand Up @@ -540,6 +551,7 @@ int main(int argc,char * argv[])

void solveEpetraSystem(panzer::LinearObjContainer & container)
{
#ifdef PANZER_HAVE_EPETRA
// convert generic linear object container to epetra container
panzer::EpetraLinearObjContainer & ep_container
= Teuchos::dyn_cast<panzer::EpetraLinearObjContainer>(container);
Expand Down Expand Up @@ -570,6 +582,7 @@ void solveEpetraSystem(panzer::LinearObjContainer & container)
// Therefore we have J*e=-J*u which implies e = -u
// thus we will scale the solution vector
ep_container.get_x()->Scale(-1.0);
#endif
}

void solveTpetraSystem(panzer::LinearObjContainer & container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

#include "PanzerAdaptersSTK_config.hpp"

#ifdef PANZER_HAVE_EPETRA

#include "Panzer_STK_ModelEvaluatorFactory.hpp"
#include "Panzer_STK_ModelEvaluatorFactory_impl.hpp"

Expand All @@ -50,3 +52,5 @@ namespace panzer_stk {
template class ModelEvaluatorFactory<double>;

}

#endif // PANZER_HAVE_EPETRA
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
// @HEADER

#include "PanzerAdaptersSTK_config.hpp"

#ifdef PANZER_HAVE_EPETRA

#include "Panzer_STK_SetupLOWSFactory.hpp"
#include "Panzer_STK_ParameterListCallback.hpp"
#include "Panzer_STK_ParameterListCallbackBlocked.hpp"
Expand Down Expand Up @@ -526,3 +529,5 @@ namespace {
return Teuchos::null;
}
}

#endif // PANZER_HAVE_EPETRA
4 changes: 4 additions & 0 deletions packages/panzer/adapters-stk/src/Panzer_STK_Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

#include "PanzerAdaptersSTK_config.hpp"

#ifdef PANZER_HAVE_EPETRA

#include "Panzer_STK_Utilities.hpp"
#include "Panzer_GlobalIndexer.hpp"

Expand Down Expand Up @@ -177,3 +179,5 @@ void build_local_ids(const panzer_stk::STK_Interface & mesh,
}

}

#endif // PANZER_HAVE_EPETRA
20 changes: 12 additions & 8 deletions packages/panzer/adapters-stk/src/Panzer_STK_Utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
// ***********************************************************************
// @HEADER

#ifdef PANZER_HAVE_EPETRA

#ifndef __Panzer_STK_Utilities_hpp__
#define __Panzer_STK_Utilities_hpp__

Expand All @@ -52,7 +54,7 @@ namespace panzer {
class GlobalIndexer;
}

namespace panzer_stk {
namespace panzer_stk {

/** Write a vector to the cell data of a STK mesh. This will look up
* the cell field <code>prefix+fieldName+postfix</code>, which is assumed
Expand All @@ -70,18 +72,18 @@ void write_solution_data(const panzer::GlobalIndexer& dofMngr,panzer_stk::STK_In
/** Using a container, compute the sorted permutation vector
* do not modifiy the original container.
*
* Motivated by this board on StackOverflow:
* Motivated by this board on StackOverflow:
* http://stackoverflow.com/questions/4523220/sorting-a-vector-of-double-precision-reals-and-obtain-their-order
*/
*/
template <typename RAContainer,class Compare>
void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation,const Compare & comp);

/** Using a container, compute the sorted permutation vector
* do not modifiy the original container.
*
* Motivated by this board on StackOverflow:
* Motivated by this board on StackOverflow:
* http://stackoverflow.com/questions/4523220/sorting-a-vector-of-double-precision-reals-and-obtain-their-order
*/
*/
template <typename RAContainer>
void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation);

Expand All @@ -91,7 +93,7 @@ namespace panzer_stk {
// utility class used by the sorted permutation objects
template <typename RAContainer,typename Compare>
struct PermFunctor {
PermFunctor(const RAContainer & cont,const Compare & comp)
PermFunctor(const RAContainer & cont,const Compare & comp)
: compare(comp), values(cont) {}
PermFunctor(const PermFunctor & p)
: compare(p.compare), values(p.values) {}
Expand All @@ -108,9 +110,9 @@ struct PermFunctor {

template <typename RAContainer>
void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation)
{
{
std::less<typename RAContainer::value_type> comp;
sorted_permutation(cont,permutation,comp);
sorted_permutation(cont,permutation,comp);
}

template <typename RAContainer,class Compare>
Expand All @@ -128,3 +130,5 @@ void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & perm
}

#endif

#endif // PANZER_HAVE_EPETRA
Loading

0 comments on commit dba5ca3

Please sign in to comment.