Skip to content

Commit

Permalink
Panzer: add (optional) prefix to response field name
Browse files Browse the repository at this point in the history
To help identify the response type on the evaluated field to help
prevent a bug when `Functional` and `ExtremeValue` responses are use at
the same time on the same field.

Before, a single node was shared and depending on the order the response
sublist for two types were added, the result would be different (correct
for the first response but wrong for the second one).

This should help fix that.
  • Loading branch information
Sidafa Conde authored and sconde committed Mar 8, 2018
1 parent afed21c commit 541e09c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ class ResponseEvaluatorFactory_ExtremeValue : public ResponseEvaluatorFactory<Ev
const std::string & quadPointField="",
const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & linearObjFactory=Teuchos::null,
const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & globalIndexer=Teuchos::null,
bool applyDirichletToDerivative=false)
bool applyDirichletToDerivative=false,
std::string in_prefix="")
: comm_(comm), cubatureDegree_(cubatureDegree), requiresCellExtreme_(requiresCellReduction), useMax_(useMax)
, quadPointField_(quadPointField), linearObjFactory_(linearObjFactory), globalIndexer_(globalIndexer)
, applyDirichletToDerivative_(applyDirichletToDerivative)
, prefix_(in_prefix)
{
TEUCHOS_ASSERT((linearObjFactory==Teuchos::null && globalIndexer==Teuchos::null) ||
(linearObjFactory!=Teuchos::null && globalIndexer!=Teuchos::null));
Expand Down Expand Up @@ -134,6 +136,7 @@ class ResponseEvaluatorFactory_ExtremeValue : public ResponseEvaluatorFactory<Ev
Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > linearObjFactory_;
Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > globalIndexer_;
bool applyDirichletToDerivative_;
std::string prefix_;
};

template <typename LO,typename GO>
Expand All @@ -146,6 +149,7 @@ struct ExtremeValueResponse_Builder : public ResponseMESupportBuilderBase {
bool applyDirichletToDerivative; // if this is set to true, then the dirichlet values will be zerod out in
// the DgDx vector

std::string prefix;
ExtremeValueResponse_Builder() : applyDirichletToDerivative(false) {}

virtual ~ExtremeValueResponse_Builder() {}
Expand All @@ -171,7 +175,7 @@ struct ExtremeValueResponse_Builder : public ResponseMESupportBuilderBase {
template <typename T>
Teuchos::RCP<panzer::ResponseEvaluatorFactoryBase> build() const
{ return Teuchos::rcp(new ResponseEvaluatorFactory_ExtremeValue<T,LO,GO>(comm,cubatureDegree,requiresCellExtreme,useMax,quadPointField,
linearObjFactory,globalIndexer,applyDirichletToDerivative)); }
linearObjFactory,globalIndexer,applyDirichletToDerivative,prefix)); }

virtual Teuchos::RCP<panzer::ResponseEvaluatorFactoryBase> buildValueFactory() const
{ return build<panzer::Traits::Residual>(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ buildAndRegisterEvaluators(const std::string & responseName,
RCP<IntegrationRule> ir = rcp(new IntegrationRule(cubatureDegree_,physicsBlock.cellData()));

Teuchos::ParameterList pl;
pl.set("Extreme Name",field);
// add prefix_ to help identify
pl.set("Extreme Name",prefix_+field);
pl.set("Field Name",field);
pl.set("IR",ir);
pl.set("Use Max",useMax_);
Expand All @@ -101,6 +102,7 @@ buildAndRegisterEvaluators(const std::string & responseName,
Teuchos::RCP<ExtremeValueScatterBase> scatterObj =
(globalIndexer_!=Teuchos::null) ? Teuchos::rcp(new ExtremeValueScatter<LO,GO>(globalIndexer_)) : Teuchos::null;
std::string field = (quadPointField_=="" ? responseName : quadPointField_);
field = prefix_+field; // add prefix to help identify

// build useful evaluator
Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ buildAndRegisterEvaluators(const std::string & responseName,
RCP<IntegrationRule> ir = rcp(new IntegrationRule(cubatureDegree_,physicsBlock.cellData()));

Teuchos::ParameterList pl;
pl.set("Integral Name",field);
pl.set("Integral Name", field);
pl.set("Integrand Name",field);
pl.set("IR",ir);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ResponseScatterEvaluator_ExtremeValue(const std::string & name,
cellExtremeValue_ = PHX::MDField<const ScalarT,panzer::Cell>(name,dl_cell);
this->addDependentField(cellExtremeValue_);

std::string n = "Functional Response Scatter: " + name;
std::string n = "Extreme Value Response Scatter: " + name;
this->setName(n);
}

Expand Down Expand Up @@ -119,7 +119,7 @@ ResponseScatterEvaluator_ExtremeValue(const std::string & integrandName,
cellExtremeValue_ = PHX::MDField<const ScalarT,panzer::Cell>(integrandName,dl_cell);
this->addDependentField(cellExtremeValue_);

std::string n = "Functional Response Scatter: " + responseName;
std::string n = "Extreme Value Response Scatter: " + responseName;
this->setName(n);
}

Expand Down

0 comments on commit 541e09c

Please sign in to comment.