00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "MesoScaleLinkProblem.hpp"
00012 #include "Albany_Utils.hpp"
00013 #include "Albany_ProblemUtils.hpp"
00014
00015 #include "Teuchos_TypeNameTraits.hpp"
00016
00017 namespace Teuchos {
00018
00019
00020
00021 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(MPI_Comm);
00022 }
00023
00024 Albany::MesoScaleLinkProblem::
00025 MesoScaleLinkProblem(const Teuchos::RCP<Teuchos::ParameterList>& params_,
00026 const Teuchos::RCP<ParamLib>& paramLib_,
00027 const int numDim_,
00028 const Teuchos::RCP<const Epetra_Comm>& comm_) :
00029 Albany::AbstractProblem(params_, paramLib_, numDim_),
00030 haveSource(false),
00031 numDim(numDim_),
00032 comm(comm_),
00033 mpi_comm(Albany::getMpiCommFromEpetraComm(*comm_)) {
00034
00035 TEUCHOS_TEST_FOR_EXCEPTION(comm->NumProc() != 1, std::logic_error,
00036 "MesoScale bridge only supports 1 master processor currently:\n\tRun with \"mpirun -np 1 Albany\"");
00037
00038 std::string& method = params->get("Name", "MesoScaleLink ");
00039 *out << "Problem Name = " << method << std::endl;
00040
00041 haveSource = params->isSublist("Source Functions");
00042
00043 matModel = params->sublist("Material Model").get("Model Name", "LinearMesoScaleLink");
00044
00045 TEUCHOS_TEST_FOR_EXCEPTION(matModel != "Bridge", std::logic_error,
00046 "Must specify \"Bridge\" for the material model in the input file.");
00047
00048 exeName = params->sublist("Material Model").get("Executable", "zzz");
00049
00050 *out << "Establishing MPI bridging link to: " << exeName << std::endl;
00051
00052
00053 numMesoPEs = params->sublist("Material Model").get("Num Meso PEs", 1);
00054
00055 interCommunicator = Teuchos::rcp(new MPI_Comm());
00056
00057
00058
00059 MPI_Comm_spawn(&exeName[0], MPI_ARGV_NULL, numMesoPEs,
00060 MPI_INFO_NULL, 0, mpi_comm, interCommunicator.get(), MPI_ERRCODES_IGNORE);
00061
00062
00063 }
00064
00065 Albany::MesoScaleLinkProblem::
00066 ~MesoScaleLinkProblem() {
00067
00068
00069
00070 for(int i = 0; i < numMesoPEs; i++)
00071
00072 MPI_Send(0, 0, MPI_INT, i, LCM::DIE, *interCommunicator.get());
00073
00074
00075 }
00076
00077
00078
00079
00080
00081 void Albany::MesoScaleLinkProblem::getRBMInfoForML(
00082 int& numPDEs, int& numMesoScaleLinkDim, int& numScalar, int& nullSpaceDim) {
00083 numPDEs = numDim;
00084 numMesoScaleLinkDim = numDim;
00085 numScalar = 0;
00086
00087 if(numDim == 1) {
00088 nullSpaceDim = 0;
00089 }
00090
00091 else {
00092 if(numDim == 2) {
00093 nullSpaceDim = 3;
00094 }
00095
00096 if(numDim == 3) {
00097 nullSpaceDim = 6;
00098 }
00099 }
00100 }
00101
00102
00103 void
00104 Albany::MesoScaleLinkProblem::
00105 buildProblem(
00106 Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> > meshSpecs,
00107 Albany::StateManager& stateMgr) {
00108
00109 TEUCHOS_TEST_FOR_EXCEPTION(meshSpecs.size() != 1, std::logic_error, "Problem supports one Material Block");
00110
00111 fm.resize(1);
00112
00113 fm[0] = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
00114 buildEvaluators(*fm[0], *meshSpecs[0], stateMgr, BUILD_RESID_FM,
00115 Teuchos::null);
00116
00117 if(meshSpecs[0]->nsNames.size() > 0)
00118
00119 constructDirichletEvaluators(*meshSpecs[0]);
00120
00121 if(meshSpecs[0]->ssNames.size() > 0)
00122
00123 constructNeumannEvaluators(meshSpecs[0]);
00124
00125 }
00126
00127 Teuchos::Array<Teuchos::RCP<const PHX::FieldTag> >
00128 Albany::MesoScaleLinkProblem::
00129 buildEvaluators(
00130 PHX::FieldManager<PHAL::AlbanyTraits>& fm0,
00131 const Albany::MeshSpecsStruct& meshSpecs,
00132 Albany::StateManager& stateMgr,
00133 Albany::FieldManagerChoice fmchoice,
00134 const Teuchos::RCP<Teuchos::ParameterList>& responseList) {
00135
00136
00137 ConstructEvaluatorsOp<MesoScaleLinkProblem> op(
00138 *this, fm0, meshSpecs, stateMgr, fmchoice, responseList);
00139 boost::mpl::for_each<PHAL::AlbanyTraits::BEvalTypes>(op);
00140 return *op.tags;
00141 }
00142
00143
00144 void
00145 Albany::MesoScaleLinkProblem::constructDirichletEvaluators(
00146 const Albany::MeshSpecsStruct& meshSpecs) {
00147
00148 std::vector<std::string> dirichletNames(neq);
00149 dirichletNames[0] = "X";
00150
00151 if(neq > 1) dirichletNames[1] = "Y";
00152
00153 if(neq > 2) dirichletNames[2] = "Z";
00154
00155 Albany::BCUtils<Albany::DirichletTraits> dirUtils;
00156 dfm = dirUtils.constructBCEvaluators(meshSpecs.nsNames, dirichletNames,
00157 this->params, this->paramLib);
00158 }
00159
00160
00161 void
00162 Albany::MesoScaleLinkProblem::constructNeumannEvaluators(
00163 const Teuchos::RCP<Albany::MeshSpecsStruct>& meshSpecs) {
00164
00165
00166
00167 Albany::BCUtils<Albany::NeumannTraits> neuUtils;
00168
00169
00170
00171 if(!neuUtils.haveBCSpecified(this->params))
00172
00173 return;
00174
00175
00176
00177 std::vector<std::string> neumannNames(neq + 1);
00178 Teuchos::Array<Teuchos::Array<int> > offsets;
00179 offsets.resize(neq + 1);
00180
00181 neumannNames[0] = "Tx";
00182 offsets[0].resize(1);
00183 offsets[0][0] = 0;
00184 offsets[neq].resize(neq);
00185 offsets[neq][0] = 0;
00186
00187 if(neq > 1) {
00188 neumannNames[1] = "Ty";
00189 offsets[1].resize(1);
00190 offsets[1][0] = 1;
00191 offsets[neq][1] = 1;
00192 }
00193
00194 if(neq > 2) {
00195 neumannNames[2] = "Tz";
00196 offsets[2].resize(1);
00197 offsets[2][0] = 2;
00198 offsets[neq][2] = 2;
00199 }
00200
00201 neumannNames[neq] = "all";
00202
00203
00204
00205 std::vector<std::string> condNames(3);
00206 Teuchos::ArrayRCP<std::string> dof_names(1);
00207 dof_names[0] = "Displacement";
00208
00209
00210 if(numDim == 2)
00211 condNames[0] = "(dudx, dudy)";
00212
00213 else if(numDim == 3)
00214 condNames[0] = "(dudx, dudy, dudz)";
00215
00216 else
00217 TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00218 std::endl << "Error: Sidesets only supported in 2 and 3D." << std::endl);
00219
00220 condNames[1] = "dudn";
00221 condNames[2] = "P";
00222
00223 nfm.resize(1);
00224
00225 nfm[0] = neuUtils.constructBCEvaluators(meshSpecs, neumannNames, dof_names, true, 0,
00226 condNames, offsets, dl,
00227 this->params, this->paramLib);
00228
00229 }
00230
00231
00232 Teuchos::RCP<const Teuchos::ParameterList>
00233 Albany::MesoScaleLinkProblem::getValidProblemParameters() const {
00234 Teuchos::RCP<Teuchos::ParameterList> validPL =
00235 this->getGenericProblemParams("ValidMesoScaleLinkProblemParams");
00236
00237 validPL->sublist("Elastic Modulus", false, "");
00238 validPL->sublist("Poissons Ratio", false, "");
00239 validPL->sublist("Material Model", false, "");
00240
00241 if(matModel == "Bridge") {
00242 validPL->set<std::string>("Executable", "zzz", "Name of mesoscale code executable file");
00243 validPL->set<int>("Num Meso PEs", false, "");
00244 }
00245
00246 return validPL;
00247 }
00248
00249 void
00250 Albany::MesoScaleLinkProblem::getAllocatedStates(
00251 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::RCP<Intrepid::FieldContainer<RealType> > > > oldState_,
00252 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::RCP<Intrepid::FieldContainer<RealType> > > > newState_
00253 ) const {
00254 oldState_ = oldState;
00255 newState_ = newState;
00256 }