forked from trilinos/Trilinos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge Pull Request trilinos#10327 from rppawlo/Trilinos/panzer-add-te…
…mpus-support Automatically Merged using Trilinos Pull Request AutoTester PR Title: Panzer add tempus support PR Author: rppawlo
- Loading branch information
Showing
12 changed files
with
878 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
453 changes: 453 additions & 0 deletions
453
packages/panzer/adapters-stk/example/main_driver/energy-transient-tempus-blocked.xml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/panzer/adapters-stk/example/main_driver/user_app_TempusObserverFactory.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// @HEADER | ||
// *********************************************************************** | ||
// | ||
// Panzer: A partial differential equation assembly | ||
// engine for strongly coupled complex multiphysics systems | ||
// Copyright (2011) Sandia Corporation | ||
// | ||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the Corporation nor the names of the | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY | ||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
// Questions? Contact Roger P. Pawlowski ([email protected]) and | ||
// Eric C. Cyr ([email protected]) | ||
// *********************************************************************** | ||
// @HEADER | ||
|
||
#ifndef USER_APP_TEMPUS_OBSERVER_FACTORY_HPP | ||
#define USER_APP_TEMPUS_OBSERVER_FACTORY_HPP | ||
|
||
#include "PanzerAdaptersSTK_config.hpp" | ||
|
||
#ifdef PANZER_HAVE_TEMPUS | ||
|
||
#include "Panzer_STK_TempusObserverFactory.hpp" | ||
#include "Panzer_ResponseLibrary.hpp" | ||
#include "Panzer_Traits.hpp" | ||
|
||
#include "Tempus_IntegratorObserverComposite.hpp" | ||
|
||
// Individual Observers | ||
#include "user_app_TempusObserver_WriteToExodus.hpp" | ||
|
||
namespace user_app { | ||
|
||
class TempusObserverFactory : public panzer_stk::TempusObserverFactory { | ||
|
||
public: | ||
TempusObserverFactory(const Teuchos::RCP<panzer::ResponseLibrary<panzer::Traits> > & stkIOResponseLibrary, | ||
const Teuchos::RCP<panzer::WorksetContainer> wkstContainer) | ||
: stkIOResponseLibrary_(stkIOResponseLibrary) | ||
, wkstContainer_(wkstContainer) | ||
{} | ||
|
||
bool useNOXObserver() const { return false; } | ||
|
||
Teuchos::RCP<Tempus::IntegratorObserver<double> > | ||
buildTempusObserver(const Teuchos::RCP<panzer_stk::STK_Interface>& mesh, | ||
const Teuchos::RCP<const panzer::GlobalIndexer> & dof_manager, | ||
const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> >& lof) const | ||
{ | ||
Teuchos::RCP<Tempus::IntegratorObserverComposite<double> > composite_observer = | ||
Teuchos::rcp(new Tempus::IntegratorObserverComposite<double>); | ||
|
||
{ | ||
Teuchos::RCP<user_app::TempusObserver_WriteToExodus> observer | ||
= Teuchos::rcp(new user_app::TempusObserver_WriteToExodus(mesh,dof_manager,lof,stkIOResponseLibrary_)); | ||
composite_observer->addObserver(observer); | ||
} | ||
|
||
return composite_observer; | ||
} | ||
|
||
private: | ||
//! Store STK IO response library...be careful, it will be modified externally | ||
Teuchos::RCP<panzer::ResponseLibrary<panzer::Traits> > stkIOResponseLibrary_; | ||
|
||
Teuchos::RCP<panzer::WorksetContainer> wkstContainer_; | ||
}; | ||
|
||
} | ||
|
||
#endif // PANZER_HAVE_TEMPUS | ||
#endif |
127 changes: 127 additions & 0 deletions
127
packages/panzer/adapters-stk/example/main_driver/user_app_TempusObserver_WriteToExodus.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// @HEADER | ||
// *********************************************************************** | ||
// | ||
// Panzer: A partial differential equation assembly | ||
// engine for strongly coupled complex multiphysics systems | ||
// Copyright (2011) Sandia Corporation | ||
// | ||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the Corporation nor the names of the | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY | ||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
// Questions? Contact Roger P. Pawlowski ([email protected]) and | ||
// Eric C. Cyr ([email protected]) | ||
// *********************************************************************** | ||
// @HEADER | ||
|
||
#ifndef USER_APP_TEMPUS_OBSERVER_WRITE_TO_EXODUS_HPP | ||
#define USER_APP_TEMPUS_OBSERVER_WRITE_TO_EXODUS_HPP | ||
|
||
#include "Tempus_Integrator.hpp" | ||
#include "Tempus_IntegratorObserver.hpp" | ||
#include "Teuchos_RCP.hpp" | ||
#include "Teuchos_Assert.hpp" | ||
|
||
#include "Panzer_STK_Interface.hpp" | ||
#include "Panzer_GlobalIndexer.hpp" | ||
#include "Panzer_STK_ResponseEvaluatorFactory_SolutionWriter.hpp" | ||
#include "Panzer_STK_Utilities.hpp" | ||
|
||
namespace user_app { | ||
|
||
class TempusObserver_WriteToExodus : public Tempus::IntegratorObserver<double> { | ||
|
||
public: | ||
|
||
TempusObserver_WriteToExodus(const Teuchos::RCP<panzer_stk::STK_Interface>& mesh, | ||
const Teuchos::RCP<const panzer::GlobalIndexer>& dof_manager, | ||
const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> >& lof, | ||
const Teuchos::RCP<panzer::ResponseLibrary<panzer::Traits> > & response_library) : | ||
m_mesh(mesh), | ||
m_dof_manager(dof_manager), | ||
m_lof(lof), | ||
m_response_library(response_library) | ||
{ | ||
// get all element blocks and add them to the list | ||
std::vector<std::string> eBlocks; | ||
mesh->getElementBlockNames(eBlocks); | ||
|
||
panzer_stk::RespFactorySolnWriter_Builder builder; | ||
builder.mesh = mesh; | ||
m_response_library->addResponse("Main Field Output",eBlocks,builder); | ||
} | ||
|
||
void observeStartIntegrator(const Tempus::Integrator<double>& integrator) override {this->writeToExodus(integrator);}; | ||
void observeStartTimeStep(const Tempus::Integrator<double>& ) override {}; | ||
void observeNextTimeStep(const Tempus::Integrator<double>& ) override {}; | ||
void observeBeforeTakeStep(const Tempus::Integrator<double>& ) override {}; | ||
void observeAfterTakeStep(const Tempus::Integrator<double>& integrator) override {this->writeToExodus(integrator);} | ||
void observeAfterCheckTimeStep(const Tempus::Integrator<double>& ) override {}; | ||
void observeEndTimeStep(const Tempus::Integrator<double>& ) override {}; | ||
void observeEndIntegrator(const Tempus::Integrator<double>& ) override {}; | ||
|
||
void writeToExodus(const Tempus::Integrator<double>& integrator) | ||
{ | ||
|
||
Teuchos::RCP<const Thyra::VectorBase<double> > solution = integrator.getSolutionHistory()->getStateTimeIndexN()->getX(); | ||
|
||
// initialize the assembly container | ||
panzer::AssemblyEngineInArgs ae_inargs; | ||
ae_inargs.container_ = m_lof->buildLinearObjContainer(); | ||
ae_inargs.ghostedContainer_ = m_lof->buildGhostedLinearObjContainer(); | ||
ae_inargs.alpha = 0.0; | ||
ae_inargs.beta = 1.0; | ||
ae_inargs.evaluate_transient_terms = false; | ||
|
||
// initialize the ghosted container | ||
m_lof->initializeGhostedContainer(panzer::LinearObjContainer::X,*ae_inargs.ghostedContainer_); | ||
|
||
{ | ||
// initialize the x vector | ||
const Teuchos::RCP<panzer::ThyraObjContainer<double> > thyraContainer | ||
= Teuchos::rcp_dynamic_cast<panzer::ThyraObjContainer<double> >(ae_inargs.container_,true); | ||
thyraContainer->set_x_th(Teuchos::rcp_const_cast<Thyra::VectorBase<double> >(solution)); | ||
} | ||
|
||
m_response_library->addResponsesToInArgs<panzer::Traits::Residual>(ae_inargs); | ||
m_response_library->evaluate<panzer::Traits::Residual>(ae_inargs); | ||
m_mesh->writeToExodus(integrator.getSolutionHistory()->getCurrentTime()); | ||
} | ||
|
||
protected: | ||
|
||
Teuchos::RCP<panzer_stk::STK_Interface> m_mesh; | ||
Teuchos::RCP<const panzer::GlobalIndexer> m_dof_manager; | ||
Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > m_lof; | ||
Teuchos::RCP<panzer::ResponseLibrary<panzer::Traits> > m_response_library; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.