• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

AAdapt_StratSolver.cpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #include "AAdapt_CopyRemesh.hpp"
00008 
00009 #include "Teuchos_TimeMonitor.hpp"
00010 
00011 namespace AAdapt {
00012 
00013 typedef stk::mesh::Entity Entity;
00014 typedef stk::mesh::EntityRank EntityRank;
00015 typedef stk::mesh::RelationIdentifier EdgeId;
00016 typedef stk::mesh::EntityKey EntityKey;
00017 
00018 //----------------------------------------------------------------------------
00019 AAdapt::CopyRemesh::
00020 CopyRemesh(const Teuchos::RCP<Teuchos::ParameterList>& params,
00021            const Teuchos::RCP<ParamLib>& param_lib,
00022            Albany::StateManager& state_mgr,
00023            const Teuchos::RCP<const Epetra_Comm>& comm) :
00024   AAdapt::AbstractAdapter(params, param_lib, state_mgr, comm),
00025   remesh_file_index_(1) {
00026 
00027   discretization_ = state_mgr_.getDiscretization();
00028 
00029   stk_discretization_ =
00030     static_cast<Albany::STKDiscretization*>(discretization_.get());
00031 
00032   stk_mesh_struct_ = stk_discretization_->getSTKMeshStruct();
00033 
00034   bulk_data_ = stk_mesh_struct_->bulkData;
00035   meta_data_ = stk_mesh_struct_->metaData;
00036 
00037   // The entity ranks
00038   node_rank_ = meta_data_->NODE_RANK;
00039   edge_rank_ = meta_data_->EDGE_RANK;
00040   face_rank_ = meta_data_->FACE_RANK;
00041   element_rank_ = meta_data_->element_rank();
00042 
00043   num_dim_ = stk_mesh_struct_->numDim;
00044 
00045   // Save the initial output file name
00046   base_exo_filename_ = stk_mesh_struct_->exoOutFile;
00047 
00048 }
00049 
00050 //----------------------------------------------------------------------------
00051 AAdapt::CopyRemesh::
00052 ~CopyRemesh() {
00053 }
00054 
00055 //----------------------------------------------------------------------------
00056 bool
00057 AAdapt::CopyRemesh::queryAdaptationCriteria() {
00058 
00059   if(adapt_params_->get<std::string>("Remesh Strategy", "None").compare("Continuous") == 0){
00060 
00061     if(iter > 1)
00062 
00063       return true;
00064 
00065     else
00066 
00067       return false;
00068 
00069   }
00070 
00071   Teuchos::Array<int> remesh_iter = adapt_params_->get<Teuchos::Array<int> >("Remesh Step Number");
00072 
00073   for(int i = 0; i < remesh_iter.size(); i++)
00074 
00075     if(iter == remesh_iter[i])
00076 
00077       return true;
00078 
00079   return false;
00080 
00081 }
00082 
00083 //----------------------------------------------------------------------------
00084 bool
00085 AAdapt::CopyRemesh::adaptMesh(const Epetra_Vector& solution, const Epetra_Vector& ovlp_solution) {
00086 
00087   std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
00088   std::cout << "Adapting mesh using AAdapt::CopyRemesh method       \n";
00089   std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
00090 
00091   // Save the current results and close the exodus file
00092 
00093   // Create a remeshed output file naming convention by adding the
00094   // remeshFileIndex ahead of the period
00095 
00096   std::ostringstream ss;
00097   std::string str = base_exo_filename_;
00098   ss << "_" << remesh_file_index_ << ".";
00099   str.replace(str.find('.'), 1, ss.str());
00100 
00101   std::cout << "Remeshing: renaming output file to - " << str << std::endl;
00102 
00103   // Open the new exodus file for results
00104   stk_discretization_->reNameExodusOutput(str);
00105 
00106   remesh_file_index_++;
00107 
00108   // do remeshing right here if we were doing any...
00109 
00110   // Throw away all the Albany data structures and re-build them
00111   // from the mesh
00112 
00113   stk_discretization_->updateMesh();
00114 
00115   return true;
00116 
00117 }
00118 
00119 //----------------------------------------------------------------------------
00120 //
00121 // Transfer solution between meshes.
00122 //
00123 void
00124 AAdapt::CopyRemesh::
00125 solutionTransfer(const Epetra_Vector& oldSolution,
00126                  Epetra_Vector& newSolution) {
00127 
00128   TEUCHOS_TEST_FOR_EXCEPT(oldSolution.MyLength() != newSolution.MyLength());
00129   newSolution = oldSolution;
00130 }
00131 
00132 //----------------------------------------------------------------------------
00133 Teuchos::RCP<const Teuchos::ParameterList>
00134 AAdapt::CopyRemesh::getValidAdapterParameters() const {
00135   Teuchos::RCP<Teuchos::ParameterList> validPL =
00136     this->getGenericAdapterParams("ValidCopyRemeshParameters");
00137 
00138   Teuchos::Array<int> defaultArgs;
00139 
00140   validPL->set<Teuchos::Array<int> >("Remesh Step Number", defaultArgs, "Iteration step at which to remesh the problem");
00141   validPL->set<std::string>("Remesh Strategy", "", "Strategy to use when remeshing: Continuous - remesh every step.");
00142 
00143   return validPL;
00144 }
00145 //----------------------------------------------------------------------------
00146 }

Generated on Wed Mar 26 2014 18:36:35 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1