Skip to content

Commit

Permalink
Adding steady option fo thermal residual evaluator.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikalash committed May 28, 2020
1 parent 4b87f2a commit 13f235d
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/evaluators/pde/PHAL_ThermalResid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ThermalResid : public PHX::EvaluatorWithBaseImpl<Traits>,
PHX::MDField<const MeshScalarT, Cell, QuadPoint, Dim> coordVec;
double C; // Heat Capacity
double rho; // Density
bool disable_transient; //Boolean to disable transient terms
// Thermal conductivity components
PHX::MDField<const ScalarT> kappa_x;
PHX::MDField<const ScalarT> kappa_y;
Expand Down
22 changes: 18 additions & 4 deletions src/evaluators/pde/PHAL_ThermalResid_Def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ ThermalResid(const Teuchos::ParameterList& p,
p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
rho(p.get<double>("Density")),
C(p.get<double>("Heat Capacity")),
disable_transient(p.get<bool>("Disable Transient")),
kappa_x(p.get<std::string>("Thermal Conductivity: kappa_x"), dl->shared_param)
{
this->addDependentField(wBF);
this->addDependentField(Tdot);
if (!disable_transient) this->addDependentField(Tdot);
this->addDependentField(TGrad);
this->addDependentField(wGradBF);
this->addDependentField(kappa_x);
Expand Down Expand Up @@ -70,6 +71,12 @@ ThermalResid(const Teuchos::ParameterList& p,
}
else if (thermal_source == "1D Cost") {
force_type = ONEDCOST;
if (disable_transient) {
TEUCHOS_TEST_FOR_EXCEPTION(
true,
std::logic_error,
"'Thermal Source = 1D Cost' is only valid for transient problems!\n");
}
}
else if (thermal_source == "2D Cost Expt") {
force_type = TWODCOSTEXPT;
Expand All @@ -80,6 +87,12 @@ ThermalResid(const Teuchos::ParameterList& p,
"'Thermal Source = 2D Cost Expt' is only valid for 2 or more spatial dimensions! " <<
"Your problem has numDims = " << numDims << " dimensions. \n");
}
if (disable_transient) {
TEUCHOS_TEST_FOR_EXCEPTION(
true,
std::logic_error,
"'Thermal Source = 2D Cost Expt' is only valid for transient problems!\n");
}
}
else {
TEUCHOS_TEST_FOR_EXCEPTION(
Expand All @@ -100,7 +113,7 @@ postRegistrationSetup(typename Traits::SetupData d,
this->utils.setFieldData(wBF, fm);
this->utils.setFieldData(TGrad, fm);
this->utils.setFieldData(wGradBF, fm);
this->utils.setFieldData(Tdot, fm);
if (!disable_transient) this->utils.setFieldData(Tdot, fm);
this->utils.setFieldData(Source, fm);
this->utils.setFieldData(coordVec, fm);
this->utils.setFieldData(TResidual, fm);
Expand Down Expand Up @@ -155,9 +168,10 @@ evaluateFields(typename Traits::EvalData workset)
TResidual(cell, node) = 0.0;
for (std::size_t qp = 0; qp < numQPs; ++qp) {
// Time-derivative contribution to residual
TResidual(cell, node) += rho * C * Tdot(cell, qp) * wBF(cell, node, qp)
if (!disable_transient)
TResidual(cell, node) += rho * C * Tdot(cell, qp) * wBF(cell, node, qp);
// Source contribution to residual
- Source(cell,qp) * wBF(cell, node, qp);
TResidual(cell, node) -= Source(cell,qp) * wBF(cell, node, qp);
// Diffusion part of residual
TResidual(cell, node) += kappa_x(0) * TGrad(cell, qp, 0) * wGradBF(cell, node, qp, 0);
if (numDims > 1) {
Expand Down
27 changes: 23 additions & 4 deletions src/problems/Albany_ThermalProblem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,24 @@ Albany::ThermalProblem::constructEvaluators(
int const numQPtsCell = cellCubature->getNumPoints();
int const numVertices = cellType->getNodeCount();

// Problem is steady or transient
// Get the solution method type
SolutionMethodType SolutionType = getSolutionMethod();

ALBANY_PANIC(
number_of_time_deriv != 1,
"Albany_ThermalProblem must be defined as transient "
"calculation.");
SolutionType == SolutionMethodType::Unknown,
"Solution Method must be Steady, Transient, "
"Continuation, or Eigensolve");

if (SolutionType == SolutionMethodType::Transient) { // Problem is transient
ALBANY_PANIC(
number_of_time_deriv != 1,
"You are using a transient solution method in Albany::ThermalProblem but number of time derivatives != 1!");
}
else { //Problem is steady
ALBANY_PANIC(
number_of_time_deriv > 0,
"You are using a steady solution method in Albany::ThermalProblem but number of time derivatives > 0!");
}

*out << "Field Dimensions: Workset=" << worksetSize
<< ", Vertices= " << numVertices << ", Nodes= " << numNodes
Expand Down Expand Up @@ -255,6 +268,12 @@ Albany::ThermalProblem::constructEvaluators(
p->set<std::string>("Thermal Conductivity: kappa_x","kappa_x Parameter");
if (numDim > 1) p->set<std::string>("Thermal Conductivity: kappa_y","kappa_y Parameter");
if (numDim > 2) p->set<std::string>("Thermal Conductivity: kappa_z","kappa_z Parameter");
if (SolutionType != SolutionMethodType::Transient) {
p->set<bool>("Disable Transient", true);
}
else {
p->set<bool>("Disable Transient", false);
}
p->set<double>("Heat Capacity", C);
p->set<double>("Density", rho);
p->set<std::string>("Thermal Source", thermal_source);
Expand Down
2 changes: 2 additions & 0 deletions tests/small/Thermal2D/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ if(NOT ALBANY_PARALLEL_ONLY)
# Copy Input file from source to binary dir
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input.yaml
${CMAKE_CURRENT_BINARY_DIR}/input.yaml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input_steady.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_steady.yaml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input_with_source.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_with_source.yaml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/compute_errs_source_no_movie2avi.m
Expand Down
116 changes: 116 additions & 0 deletions tests/small/Thermal2D/input_steady.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
ALBANY:
Debug Output:
Write Solution to MatrixMarket: 0
Problem:
Name: Thermal 2D
Solution Method: Steady
Compute Sensitivities: true
Dirichlet BCs:
SDBC on NS NodeSet0 for DOF T: 0.0
SDBC on NS NodeSet1 for DOF T: 50.0
SDBC on NS NodeSet2 for DOF T: 0.0
SDBC on NS NodeSet3 for DOF T: 0.0
Initial Condition:
Function: Constant
Function Data: [0.0]
Thermal Conductivity: [1.6, 0.8]
Heat Capacity: 1.0
Density: 1.0
Thermal Source: None
Response Functions:
Number: 1
Response 0: Solution Average
Parameters:
Number of Parameter Vectors: 2
Parameter Vector 0:
Number: 1
Parameter 0: 'kappa_x Parameter'
Nominal Values: [1.6]
Parameter Vector 1:
Number: 1
Parameter 0: 'kappa_y Parameter'
Nominal Values: [0.8]
#Parameters:
# Number: 2
# Parameter 0: 'kappa_x Parameter'
# Parameter 1: 'kappa_y Parameter'
Discretization:
1D Elements: 3
2D Elements: 3
1D Scale: 1.00000000000000000e+00
2D Scale: 1.00000000000000000e+00
Workset Size: -1
Method: STK2D
Exodus Output File Name: thermal2D_with_source_out.exo
Regression Results:
Number of Comparisons: 1
Test Values: [-4.391538524980e+01]
#Sensitivity Comparisons 0:
# Number of Sensitivity Comparisons: 2
# Sensitivity Test Values 0: [0.0]
# Sensitivity Test Values 1: [5.62650000000000025e-02]
Relative Tolerance: 1.00000000000000002e-03
Absolute Tolerance: 1.00000000000000008e-05
Piro:
Sensitivity Method: Forward
LOCA:
Bifurcation: { }
Constraints: { }
Predictor:
First Step Predictor: { }
Last Step Predictor: { }
Step Size: { }
Stepper:
Eigensolver: { }
NOX:
Direction:
Method: Newton
Newton:
Forcing Term Method: Constant
Rescue Bad Newton Solve: true
Stratimikos Linear Solver:
NOX Stratimikos Options: { }
Stratimikos:
Linear Solver Type: Belos
Linear Solver Types:
AztecOO:
Forward Solve:
AztecOO Settings:
Aztec Solver: GMRES
Convergence Test: r0
Size of Krylov Subspace: 200
Output Frequency: 10
Max Iterations: 200
Tolerance: 1.00000000000000008e-05
Belos:
Solver Type: Block GMRES
Solver Types:
Block GMRES:
Convergence Tolerance: 1.00000000000000008e-05
Output Frequency: 10
Output Style: 1
Verbosity: 33
Maximum Iterations: 100
Block Size: 1
Num Blocks: 50
Flexible Gmres: false
Preconditioner Type: Ifpack2
Preconditioner Types:
Ifpack2:
Overlap: 1
Prec Type: ILUT
Ifpack2 Settings:
'fact: drop tolerance': 0.00000000000000000e+00
'fact: ilut level-of-fill': 1.00000000000000000e+00
'fact: level-of-fill': 1
Line Search:
Full Step:
Full Step: 1.00000000000000000e+00
Method: Full Step
Nonlinear Solver: Line Search Based
Printing:
Output Information: 103
Output Precision: 3
Solver Options:
Status Test Check Type: Minimal
...

0 comments on commit 13f235d

Please sign in to comment.