00001
00002
00003
00004
00005
00006
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Albany_DiscretizationFactory.hpp"
00009 #include "Albany_STKDiscretization.hpp"
00010 #include "Albany_TmplSTKMeshStruct.hpp"
00011 #include "Albany_GenericSTKMeshStruct.hpp"
00012
00013 #ifdef ALBANY_SEACAS
00014 #include "Albany_IossSTKMeshStruct.hpp"
00015 #endif
00016 #include "Albany_AsciiSTKMeshStruct.hpp"
00017 #include "Albany_CismSTKMeshStruct.hpp"
00018 #include "Albany_AsciiSTKMesh2D.hpp"
00019 #include "Albany_ExtrudedSTKMeshStruct.hpp"
00020 #include "Albany_MpasSTKMeshStruct.hpp"
00021 #ifdef ALBANY_CUTR
00022 #include "Albany_FromCubitSTKMeshStruct.hpp"
00023 #endif
00024 #ifdef ALBANY_SCOREC
00025 #include "AlbPUMI_FMDBDiscretization.hpp"
00026 #include "AlbPUMI_FMDBMeshStruct.hpp"
00027 #endif
00028 #ifdef ALBANY_CATALYST
00029 #include "Albany_Catalyst_Decorator.hpp"
00030 #endif
00031
00032 Albany::DiscretizationFactory::DiscretizationFactory(
00033 const Teuchos::RCP<Teuchos::ParameterList>& topLevelParams,
00034 const Teuchos::RCP<const Epetra_Comm>& epetra_comm_) :
00035 epetra_comm(epetra_comm_) {
00036
00037 discParams = Teuchos::sublist(topLevelParams, "Discretization", true);
00038
00039 if(topLevelParams->isSublist("Piro"))
00040
00041 piroParams = Teuchos::sublist(topLevelParams, "Piro", true);
00042
00043 if(topLevelParams->isSublist("Problem")) {
00044
00045 Teuchos::RCP<Teuchos::ParameterList> problemParams = Teuchos::sublist(topLevelParams, "Problem", true);
00046
00047 if(problemParams->isSublist("Adaptation"))
00048
00049 adaptParams = Teuchos::sublist(problemParams, "Adaptation", true);
00050
00051 if(problemParams->isSublist("Catalyst"))
00052
00053 catalystParams = Teuchos::sublist(problemParams, "Catalyst", true);
00054
00055 }
00056
00057 }
00058
00059 #ifdef ALBANY_CUTR
00060 void
00061 Albany::DiscretizationFactory::setMeshMover(const Teuchos::RCP<CUTR::CubitMeshMover>& meshMover_) {
00062 meshMover = meshMover_;
00063 }
00064 #endif
00065
00066 Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> >
00067 Albany::DiscretizationFactory::createMeshSpecs() {
00068 std::string& method = discParams->get("Method", "STK1D");
00069
00070 if(method == "STK1D") {
00071 meshStruct = Teuchos::rcp(new Albany::TmplSTKMeshStruct<1>(discParams, adaptParams, epetra_comm));
00072 }
00073
00074 else if(method == "STK0D") {
00075 meshStruct = Teuchos::rcp(new Albany::TmplSTKMeshStruct<0>(discParams, adaptParams, epetra_comm));
00076 }
00077
00078 else if(method == "STK2D") {
00079 meshStruct = Teuchos::rcp(new Albany::TmplSTKMeshStruct<2>(discParams, adaptParams, epetra_comm));
00080 }
00081
00082 else if(method == "STK3D") {
00083 meshStruct = Teuchos::rcp(new Albany::TmplSTKMeshStruct<3>(discParams, adaptParams, epetra_comm));
00084 }
00085
00086 else if(method == "Ioss" || method == "Exodus" || method == "Pamgen") {
00087 #ifdef ALBANY_SEACAS
00088 meshStruct = Teuchos::rcp(new Albany::IossSTKMeshStruct(discParams, adaptParams, epetra_comm));
00089 #else
00090 TEUCHOS_TEST_FOR_EXCEPTION(method == "Ioss" || method == "Exodus" || method == "Pamgen",
00091 Teuchos::Exceptions::InvalidParameter,
00092 "Error: Discretization method " << method
00093 << " requested, but not compiled in" << std::endl);
00094 #endif
00095 }
00096
00097 else if(method == "Ascii") {
00098 meshStruct = Teuchos::rcp(new Albany::AsciiSTKMeshStruct(discParams, epetra_comm));
00099 }
00100 else if(method == "Cism") {
00101 meshStruct = discParams->get<Teuchos::RCP<Albany::AbstractSTKMeshStruct> >("STKMeshStruct");
00102 }
00103 else if(method == "Ascii2D") {
00104 Teuchos::RCP<Albany::GenericSTKMeshStruct> meshStruct2D;
00105 meshStruct2D = Teuchos::rcp(new Albany::AsciiSTKMesh2D(discParams, epetra_comm));
00106 Teuchos::RCP<Albany::StateInfoStruct> sis=Teuchos::rcp(new Albany::StateInfoStruct);
00107 Albany::AbstractFieldContainer::FieldContainerRequirements req;
00108
00109
00110
00111
00112 int neq=2;
00113 meshStruct2D->setFieldAndBulkData(epetra_comm, discParams, neq, req,
00114 sis, meshStruct2D->getMeshSpecs()[0]->worksetSize);
00115 Ioss::Init::Initializer io;
00116 Teuchos::RCP<stk::io::MeshData> mesh_data =Teuchos::rcp(new stk::io::MeshData);
00117 stk::io::create_output_mesh("IceSheet.exo", MPI_COMM_WORLD, *meshStruct2D->bulkData, *mesh_data);
00118 stk::io::define_output_fields(*mesh_data, *meshStruct2D->metaData);
00119 stk::io::process_output_request(*mesh_data, *meshStruct2D->bulkData, 0.0);
00120 }
00121 else if(method == "Extruded") {
00122 meshStruct = Teuchos::rcp(new Albany::ExtrudedSTKMeshStruct(discParams, epetra_comm));
00123 }
00124 else if (method == "Mpas") {
00125 meshStruct = discParams->get<Teuchos::RCP<Albany::AbstractSTKMeshStruct> >("STKMeshStruct");
00126 }
00127 else if(method == "Cubit") {
00128 #ifdef ALBANY_CUTR
00129 AGS"need to inherit from Generic"
00130 meshStruct = Teuchos::rcp(new Albany::FromCubitSTKMeshStruct(meshMover, discParams, neq));
00131 #else
00132 TEUCHOS_TEST_FOR_EXCEPTION(method == "Cubit",
00133 Teuchos::Exceptions::InvalidParameter,
00134 "Error: Discretization method " << method
00135 << " requested, but not compiled in" << std::endl);
00136 #endif
00137 }
00138
00139 else if(method == "FMDB") {
00140 #ifdef ALBANY_SCOREC
00141 meshStruct = Teuchos::rcp(new AlbPUMI::FMDBMeshStruct(discParams, epetra_comm));
00142 #else
00143 TEUCHOS_TEST_FOR_EXCEPTION(method == "FMDB",
00144 Teuchos::Exceptions::InvalidParameter,
00145 "Error: Discretization method " << method
00146 << " requested, but not compiled in" << std::endl);
00147 #endif
00148 }
00149
00150 else {
00151 TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter, std::endl <<
00152 "Error! Unknown discretization method in DiscretizationFactory: " << method <<
00153 "!" << std::endl << "Supplied parameter list is " << std::endl << *discParams
00154 << "\nValid Methods are: STK1D, STK2D, STK3D, Ioss, Exodus, Cubit, FMDB" << std::endl);
00155 }
00156
00157 return meshStruct->getMeshSpecs();
00158
00159 }
00160
00161 Teuchos::RCP<Albany::AbstractDiscretization>
00162 Albany::DiscretizationFactory::createDiscretization(unsigned int neq,
00163 const Teuchos::RCP<Albany::StateInfoStruct>& sis,
00164 const AbstractFieldContainer::FieldContainerRequirements& req,
00165 const Teuchos::RCP<Piro::MLRigidBodyModes>& rigidBodyModes) {
00166 TEUCHOS_TEST_FOR_EXCEPTION(meshStruct == Teuchos::null,
00167 std::logic_error,
00168 "meshStruct accessed, but it has not been constructed" << std::endl);
00169
00170 setupInternalMeshStruct(neq, sis, req);
00171 Teuchos::RCP<Albany::AbstractDiscretization> result =
00172 createDiscretizationFromInternalMeshStruct(rigidBodyModes);
00173
00174
00175 #ifdef ALBANY_CATALYST
00176
00177 if(Teuchos::nonnull(catalystParams) && catalystParams->get<bool>("Interface Activated", false))
00178 result = Teuchos::rcp(static_cast<Albany::AbstractDiscretization*>(
00179 new Catalyst::Decorator(result, catalystParams)));
00180
00181 #endif
00182
00183 return result;
00184 }
00185
00186 void
00187 Albany::DiscretizationFactory::setupInternalMeshStruct(
00188 unsigned int neq,
00189 const Teuchos::RCP<Albany::StateInfoStruct>& sis,
00190 const AbstractFieldContainer::FieldContainerRequirements& req) {
00191 meshStruct->setFieldAndBulkData(epetra_comm, discParams, neq, req,
00192 sis, meshStruct->getMeshSpecs()[0]->worksetSize);
00193 }
00194
00195 Teuchos::RCP<Albany::AbstractDiscretization>
00196 Albany::DiscretizationFactory::createDiscretizationFromInternalMeshStruct(
00197 const Teuchos::RCP<Piro::MLRigidBodyModes>& rigidBodyModes) {
00198
00199 if(!piroParams.is_null() && !rigidBodyModes.is_null())
00200
00201 rigidBodyModes->setPiroPL(piroParams);
00202
00203 switch(meshStruct->meshSpecsType()) {
00204
00205 case Albany::AbstractMeshStruct::STK_MS: {
00206 Teuchos::RCP<Albany::AbstractSTKMeshStruct> ms = Teuchos::rcp_dynamic_cast<Albany::AbstractSTKMeshStruct>(meshStruct);
00207 return Teuchos::rcp(new Albany::STKDiscretization(ms, epetra_comm, rigidBodyModes));
00208 }
00209 break;
00210
00211 #ifdef ALBANY_SCOREC
00212
00213 case Albany::AbstractMeshStruct::FMDB_VTK_MS: {
00214 Teuchos::RCP<AlbPUMI::FMDBMeshStruct> ms = Teuchos::rcp_dynamic_cast<AlbPUMI::FMDBMeshStruct>(meshStruct);
00215 return Teuchos::rcp(new AlbPUMI::FMDBDiscretization<AlbPUMI::FMDBVtk>(ms, epetra_comm, rigidBodyModes));
00216 }
00217 break;
00218
00219 case Albany::AbstractMeshStruct::FMDB_EXODUS_MS: {
00220 Teuchos::RCP<AlbPUMI::FMDBMeshStruct> ms = Teuchos::rcp_dynamic_cast<AlbPUMI::FMDBMeshStruct>(meshStruct);
00221 return Teuchos::rcp(new AlbPUMI::FMDBDiscretization<AlbPUMI::FMDBExodus>(ms, epetra_comm, rigidBodyModes));
00222 }
00223 break;
00224 #endif
00225
00226 }
00227 }