Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "Teuchos_RCP.hpp"
00008 #include "Teuchos_TestForException.hpp"
00009 #include "Epetra_MultiVector.h"
00010
00011 #include "Albany_StateInfoStruct.hpp"
00012 #include "Albany_Application.hpp"
00013 #include "QCAD_MultiSolutionObserver.hpp"
00014 #include "QCAD_CoupledPSObserver.hpp"
00015
00016
00018
00020
00021 QCAD::CoupledPS_NOXObserver::CoupledPS_NOXObserver(const Teuchos::RCP<CoupledPoissonSchrodinger> &psModel) :
00022 psModel_(psModel)
00023 {
00024
00025 }
00026
00027 void QCAD::CoupledPS_NOXObserver::observeSolution(const Epetra_Vector& solution)
00028 {
00029
00030 observeSolution(solution, 0.0);
00031 }
00032
00033 void QCAD::CoupledPS_NOXObserver::observeSolution(
00034 const Epetra_Vector& solution, double time_or_param_val)
00035 {
00036 Teuchos::RCP<const Epetra_Vector> soln_poisson, soln_eigenvals_dist;
00037 Teuchos::RCP<const Epetra_MultiVector> soln_schrodinger;
00038
00039 psModel_->separateCombinedVector(Teuchos::rcp(&solution, false),
00040 soln_poisson, soln_schrodinger, soln_eigenvals_dist);
00041
00042 int nEigenvals = soln_eigenvals_dist->Map().NumGlobalElements();
00043 Teuchos::RCP<Albany::Application> poisson_app = psModel_->getPoissonApp();
00044 Teuchos::RCP<Albany::Application> schrodinger_app = psModel_->getSchrodingerApp();
00045
00046
00047 poisson_app->evaluateStateFieldManager(time_or_param_val, NULL, NULL, *soln_poisson);
00048 for(int i=0; i<nEigenvals; i++)
00049 schrodinger_app->evaluateStateFieldManager(time_or_param_val, NULL, NULL, *((*soln_schrodinger)(i)) );
00050
00051
00052
00053 poisson_app->getStateMgr().updateStates();
00054 schrodinger_app->getStateMgr().updateStates();
00055
00056
00057
00058
00059
00060
00061 Epetra_Vector *poisson_ovlp_solution = poisson_app->getAdaptSolMgr()->getOverlapSolution(*soln_poisson);
00062 poisson_app->getDiscretization()->writeSolution(*poisson_ovlp_solution, time_or_param_val, true);
00063
00064 for(int i=0; i<nEigenvals; i++) {
00065 Epetra_Vector *schrodinger_ovlp_solution = schrodinger_app->getAdaptSolMgr()->getOverlapSolution(*((*soln_schrodinger)(i)));
00066 schrodinger_app->getDiscretization()->writeSolution(*schrodinger_ovlp_solution, time_or_param_val + i*0.1, true);
00067 }
00068
00069 soln_eigenvals_dist->Print(std::cout << "Coupled PS Solution Eigenvalues:" << std::endl);
00070
00071
00072 Albany::StateArrays& psDiscStates = psModel_->getDiscretization()->getStateArrays();
00073 Albany::StateArrays& psPoissonStates = poisson_app->getDiscretization()->getStateArrays();
00074 Teuchos::RCP<Albany::StateInfoStruct> stateInfo = poisson_app->getStateMgr().getStateInfoStruct();
00075 QCAD::CopyAllStates(psPoissonStates, psDiscStates, stateInfo);
00076
00077
00078
00079 psModel_->getDiscretization()->writeSolution(solution, time_or_param_val, false);
00080 }
00081
00082
00083
00084
00086
00088
00089 QCAD::CoupledPS_NOXObserverFactory::CoupledPS_NOXObserverFactory(const Teuchos::RCP<CoupledPoissonSchrodinger> &psModel) :
00090 psModel_(psModel)
00091 {}
00092
00093 Teuchos::RCP<NOX::Epetra::Observer>
00094 QCAD::CoupledPS_NOXObserverFactory::createInstance()
00095 {
00096 Teuchos::RCP<NOX::Epetra::Observer> result(new QCAD::CoupledPS_NOXObserver(psModel_));
00097
00098
00099
00100 return result;
00101 }
00102
00103
00104
00106
00108
00109 Teuchos::RCP<NOX::Epetra::Observer>
00110 QCAD::CoupledPS_NOXObserverConstructor::getInstance(const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
00111 {
00112 if (Teuchos::is_null(instance_)) {
00113 instance_ = factory_.createInstance();
00114 }
00115 return instance_;
00116 }
00117
00118