Skip to content

Commit

Permalink
Putting in ifdef guards to allow use to compile code
Browse files Browse the repository at this point in the history
even when STKExprEval is not on in Trilinos.

Sorry, @mperego, for not doing this earlier.
  • Loading branch information
[email protected] committed Apr 19, 2020
1 parent f509195 commit e50c9f0
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (NOT SET_COMPILERS_AUTOMATICALLY)
project(Albany CXX C Fortran)
endif ()


# Advertise that we support shared libs
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)

Expand Down Expand Up @@ -370,6 +371,16 @@ IF (have_stk_List_ID GREATER -1)
SET(ALBANY_STK_PERCEPT FALSE)
ENDIF()

#set optional dependency on STKExprEval
LIST(FIND Trilinos_PACKAGE_LIST STKExprEval STKExprEval_List_ID)
IF (STKExprEval_List_ID GREATER -1)
MESSAGE(" -- Looking for STKExprEval: Found. Compiling with -DALBANY_STK_EXPR_EVAL.")
SET(ALBANY_STK_EXPR_EVAL TRUE)
add_definitions(-DALBANY_STK_EXPR_EVAL)
ELSE()
MESSAGE(" -- Looking for STKExprEval: NOT Found.")
SET(ALBANY_STK_EXPR_EVAL FALSE)
ENDIF()
ELSE()
MESSAGE("-- Looking for STK: NOT found.")
SET(ALBANY_STK FALSE)
Expand Down
13 changes: 10 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ ENDIF ()
#evaluators
SET(SOURCES ${SOURCES}
evaluators/bc/PHAL_Dirichlet.cpp
evaluators/bc/PHAL_ExprEvalSDBC.cpp
evaluators/bc/PHAL_TimeDepDBC.cpp
evaluators/bc/PHAL_TimeDepSDBC.cpp
evaluators/bc/PHAL_SDirichlet.cpp
Expand Down Expand Up @@ -368,6 +367,10 @@ SET(SOURCES ${SOURCES}
IF (ALBANY_STK)
SET(SOURCES ${SOURCES}
evaluators/state/PHAL_SaveSideSetStateField.cpp)
IF(ALBANY_STK_EXPR_EVAL)
SET(SOURCES ${SOURCES}
evaluators/bc/PHAL_ExprEvalSDBC.cpp)
ENDIF()
ENDIF()

IF (ALBANY_EPETRA)
Expand Down Expand Up @@ -411,7 +414,6 @@ SET(PDE_SRCS ${PDE_SRCS}

SET(HEADERS ${HEADERS}
evaluators/bc/PHAL_Dirichlet.hpp
evaluators/bc/PHAL_ExprEvalSDBC.hpp
evaluators/bc/PHAL_TimeDepDBC.hpp
evaluators/bc/PHAL_TimeDepSDBC.hpp
evaluators/bc/PHAL_SDirichlet.hpp
Expand All @@ -424,7 +426,6 @@ SET(HEADERS ${HEADERS}
evaluators/bc/PHAL_DirichletOffNodeSet.hpp
evaluators/bc/PHAL_DirichletOffNodeSet_Def.hpp
evaluators/bc/PHAL_Dirichlet_Def.hpp
evaluators/bc/PHAL_ExprEvalSDBC_Def.hpp
evaluators/bc/PHAL_TimeDepDBC_Def.hpp
evaluators/bc/PHAL_TimeDepSDBC_Def.hpp
evaluators/bc/PHAL_SDirichlet_Def.hpp
Expand Down Expand Up @@ -552,11 +553,17 @@ SET(HEADERS ${HEADERS}
evaluators/utility/QCAD_MeshRegion.hpp
evaluators/utility/QCAD_MeshRegion_Def.hpp
)


IF (ALBANY_STK)
SET(HEADERS ${HEADERS}
evaluators/state/PHAL_SaveSideSetStateField.hpp
evaluators/state/PHAL_SaveSideSetStateField_Def.hpp)
IF(ALBANY_STK_EXPR_EVAL)
SET(HEADERS ${HEADERS}
evaluators/bc/PHAL_ExprEvalSDBC.hpp
evaluators/bc/PHAL_ExprEvalSDBC_Def.hpp)
ENDIF()
ENDIF()


Expand Down
41 changes: 22 additions & 19 deletions src/PHAL_FactoryTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ namespace PHAL {
static const int id_dirichlet_coordinate_function = 2;
static const int id_dirichlet_field = 3;
static const int id_dirichlet_off_nodeset = 4; // To handle equations on side set (see PHAL_DirichletOffNodeSet)
static const int id_timedep_bc = 5; // Only for LCM probs
static const int id_timedep_sdbc = 6; // Only for LCM probs
static const int id_timedep_bc = 5;
static const int id_timedep_sdbc = 6;
static const int id_sdbc = 7;
static int const id_expreval_sdbc = 8;
static const int id_sdirichlet_field = 9;
static const int id_kfield_bc = 10; // Only for LCM probs
static const int id_eq_concentration_bc = 11; // Only for LCM probs
static const int id_time = 12; // Only for LCM probs
static const int id_torsion_bc = 13; // Only for LCM probs
static const int id_schwarz_bc = 14; // Only for LCM probs
static const int id_strong_schwarz_bc = 15; // Only for LCM probs
static const int id_sdirichlet_field = 8;
static const int id_kfield_bc = 9; // Only for LCM probs
static const int id_eq_concentration_bc = 10; // Only for LCM probs
static const int id_time = 11; // Only for LCM probs
static const int id_torsion_bc = 12; // Only for LCM probs
static const int id_schwarz_bc = 13; // Only for LCM probs
static const int id_strong_schwarz_bc = 14; // Only for LCM probs
static int const id_expreval_sdbc = 15; // Only if ALBANY_STK_EXPR_EVAL is ON

typedef Sacado::mpl::vector<
PHAL::Dirichlet<_,Traits>, // 0
Expand All @@ -92,20 +92,23 @@ namespace PHAL {
PHAL::TimeDepDBC<_, Traits>, // 5
PHAL::TimeDepSDBC<_, Traits>, // 6
PHAL::SDirichlet<_, Traits>, // 7
PHAL::ExprEvalSDBC<_, Traits>, // 8
PHAL::SDirichletField<_, Traits> // 9
PHAL::SDirichletField<_, Traits> // 8
#if defined(ALBANY_LCM)
,
LCM::KfieldBC<_,Traits>, // 10
LCM::EquilibriumConcentrationBC<_,Traits>, // 11
LCM::Time<_, Traits>, // 12
LCM::TorsionBC<_, Traits> // 13
LCM::KfieldBC<_,Traits>, // 9
LCM::EquilibriumConcentrationBC<_,Traits>, // 10
LCM::Time<_, Traits>, // 11
LCM::TorsionBC<_, Traits> // 12
#endif
#if defined(ALBANY_LCM) && defined(ALBANY_STK)
,
LCM::SchwarzBC<_, Traits>, // 14
LCM::StrongSchwarzBC<_, Traits>, // 15
LCM::PDNeighborFitBC<_, Traits> // 16
LCM::SchwarzBC<_, Traits>, // 13
LCM::StrongSchwarzBC<_, Traits>, // 14
LCM::PDNeighborFitBC<_, Traits> // 15
#endif
#ifdef ALBANY_STK_EXPR_EVAL
,
PHAL::ExprEvalSDBC<_, Traits> // 16
#endif
> EvaluatorTypes;
};
Expand Down
4 changes: 4 additions & 0 deletions src/adapt/AAdapt_AnalyticFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include "Teuchos_TestForException.hpp"
#include "Teuchos_Exceptions.hpp"
#include "Albany_Macros.hpp"
#ifdef ALBANY_STK_EXPR_EVAL
#include <stk_expreval/Evaluator.hpp>
#endif

#include "Aeras_ShallowWaterConstants.hpp"

Expand Down Expand Up @@ -2913,6 +2915,7 @@ void AAdapt::ExpressionParser::compute(double* solution, const double* X) {
return;
}

#ifdef ALBANY_STK_EXPR_EVAL
AAdapt::ExpressionParserAllDOFs::ExpressionParserAllDOFs(
int neq_,
int dim_,
Expand Down Expand Up @@ -2940,3 +2943,4 @@ AAdapt::ExpressionParserAllDOFs::compute(double* unknowns, double const* coords)
unknowns[eq] = expr_eval.evaluate();
}
}
#endif
3 changes: 2 additions & 1 deletion src/adapt/AAdapt_AnalyticFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ class ExpressionParser : public AnalyticFunction {
#endif
};

#ifdef ALBANY_STK_EXPR_EVAL
class ExpressionParserAllDOFs : public AnalyticFunction
{
public:
Expand All @@ -648,7 +649,7 @@ class ExpressionParserAllDOFs : public AnalyticFunction
int neq; // size of solution vector x
Teuchos::Array<std::string> expr;
};

#endif
}

#endif
8 changes: 6 additions & 2 deletions src/adapt/AAdapt_InitialCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ void InitialConditions (const Teuchos::RCP<Thyra_Vector>& soln,
}
}
}
} else if (name == "Expression Parser All DOFs") {
}
#ifdef ALBANY_STK_EXPR_EVAL
else if (name == "Expression Parser All DOFs") {
Teuchos::Array<std::string> default_expr(neq);
for (auto i = 0; i < default_expr.size(); ++i) { default_expr[i] = "0.0"; }
Teuchos::Array<std::string> expr =
Expand All @@ -234,7 +236,9 @@ void InitialConditions (const Teuchos::RCP<Thyra_Vector>& soln,
}
}
}
} else {
}
#endif
else {
Teuchos::Array<double> defaultData(neq);
Teuchos::Array<double> data = icParams.get("Function Data", defaultData);

Expand Down
3 changes: 2 additions & 1 deletion src/problems/Albany_BCUtils_Def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ Albany::BCUtils<Albany::DirichletTraits>::buildEvaluatorsList(
}
}
}
#ifdef ALBANY_STK_EXPR_EVAL
///
/// Expression Evaluated SDBC (S = "Symmetric", f.k.a. "Strong")
///
Expand Down Expand Up @@ -757,7 +758,7 @@ Albany::BCUtils<Albany::DirichletTraits>::buildEvaluatorsList(
}
}
}

#endif
///
///
/// Scaled SDBC (S = "Symmetric", f.k.a. "Strong")
Expand Down
2 changes: 2 additions & 0 deletions tests/small/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ ENDIF ()
add_subdirectory(Heat2DTriangles)
add_subdirectory(Heat1DWithSource)
add_subdirectory(MPNIQuad2D)
IF(ALBANY_EXPR_EVAL_SDBC)
add_subdirectory(Thermal1D)
ENDIF()
add_subdirectory(TransientHeat1D)
add_subdirectory(TransientHeat2D)
add_subdirectory(HeatEigenvalues)
Expand Down

0 comments on commit e50c9f0

Please sign in to comment.