00001
00002
00003
00004
00005
00006
00007 #if !defined(LCM_SchwarzMultiscaleProblem_hpp)
00008 #define LCM_SchwarzMultiscaleProblem_hpp
00009
00010 #include "Teuchos_RCP.hpp"
00011 #include "Teuchos_ParameterList.hpp"
00012
00013 #include "Albany_AbstractProblem.hpp"
00014
00015 #include "Phalanx.hpp"
00016 #include "PHAL_Workset.hpp"
00017 #include "PHAL_Dimension.hpp"
00018 #include "PHAL_AlbanyTraits.hpp"
00019
00020 namespace Albany {
00021
00025 class SchwarzMultiscaleProblem : public Albany::AbstractProblem {
00026 public:
00027
00028 typedef Intrepid::FieldContainer<RealType> FC;
00029
00033 SchwarzMultiscaleProblem(
00034 Teuchos::RCP<Teuchos::ParameterList> const & params,
00035 Teuchos::RCP<ParamLib> const & param_lib,
00036 int const num_dims,
00037 Teuchos::RCP<const Epetra_Comm> const & comm);
00038
00042 virtual
00043 ~SchwarzMultiscaleProblem();
00044
00046 Teuchos::RCP<std::map<std::string, std::string> >
00047 constructFieldNameMap(bool surface_flag);
00048
00052 virtual
00053 int
00054 spatialDimension() const {return num_dims_;}
00055
00059 virtual
00060 void
00061 buildProblem(
00062 Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> > mesh_specs,
00063 StateManager & state_mgr);
00064
00068 virtual
00069 Teuchos::Array< Teuchos::RCP<const PHX::FieldTag> >
00070 buildEvaluators(
00071 PHX::FieldManager<PHAL::AlbanyTraits> & fm0,
00072 Albany::MeshSpecsStruct const & mesh_specs,
00073 Albany::StateManager & state_mgr,
00074 Albany::FieldManagerChoice fm_choice,
00075 Teuchos::RCP<Teuchos::ParameterList> const & response_list);
00076
00080 Teuchos::RCP<Teuchos::ParameterList const>
00081 getValidProblemParameters() const;
00082
00086 void
00087 getAllocatedStates(
00088 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::RCP<FC> > > old_state,
00089 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::RCP<FC> > > new_state
00090 ) const;
00091
00092 private:
00093
00097 SchwarzMultiscaleProblem(SchwarzMultiscaleProblem const &);
00098
00102 SchwarzMultiscaleProblem &
00103 operator=(SchwarzMultiscaleProblem const &);
00104
00105 QCAD::MaterialDatabase &
00106 matDB()
00107 {return *material_db_;}
00108
00109 public:
00110
00115 template <typename EvalT>
00116 Teuchos::RCP<const PHX::FieldTag>
00117 constructEvaluators(
00118 PHX::FieldManager<PHAL::AlbanyTraits> & fm0,
00119 Albany::MeshSpecsStruct const & mesh_specs,
00120 Albany::StateManager & state_mgr,
00121 Albany::FieldManagerChoice fm_choice,
00122 Teuchos::RCP<Teuchos::ParameterList> & response_list);
00123
00127 void
00128 constructDirichletEvaluators(Albany::MeshSpecsStruct const & mesh_specs);
00129
00130 protected:
00131
00135 bool have_source_;
00136
00140 int num_dims_;
00141
00145 int num_pts_;
00146
00150 int num_nodes_;
00151
00155 int num_vertices_;
00156
00160 std::map< std::string, bool > overlap_map_;
00161
00165 Teuchos::RCP<QCAD::MaterialDatabase> material_db_;
00166
00170 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::RCP<FC> > > old_state_;
00171
00175 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::RCP<FC> > > new_state_;
00176
00177 };
00178
00179 }
00180
00181
00182 #include "Albany_Utils.hpp"
00183 #include "Albany_ProblemUtils.hpp"
00184 #include "Albany_ResponseUtilities.hpp"
00185 #include "Albany_EvaluatorUtils.hpp"
00186 #include "PHAL_NSMaterialProperty.hpp"
00187 #include "PHAL_Source.hpp"
00188 #include "PHAL_SaveStateField.hpp"
00189
00190 #include "FieldNameMap.hpp"
00191
00192 #include "MechanicsResidual.hpp"
00193 #include "Time.hpp"
00194
00195
00196 #include "Kinematics.hpp"
00197 #include "ConstitutiveModelInterface.hpp"
00198 #include "ConstitutiveModelParameters.hpp"
00199
00200
00201
00202
00203 template <typename EvalT>
00204 Teuchos::RCP<const PHX::FieldTag>
00205 Albany::SchwarzMultiscaleProblem::
00206 constructEvaluators(
00207 PHX::FieldManager<PHAL::AlbanyTraits> & fm0,
00208 Albany::MeshSpecsStruct const & mesh_specs,
00209 Albany::StateManager & state_mgr,
00210 Albany::FieldManagerChoice fm_choice,
00211 Teuchos::RCP<Teuchos::ParameterList> & response_list)
00212 {
00213 using Teuchos::RCP;
00214 using Teuchos::rcp;
00215 using Teuchos::ParameterList;
00216 using PHX::DataLayout;
00217 using PHX::MDALayout;
00218 using std::vector;
00219 using PHAL::AlbanyTraits;
00220 using shards::CellTopology;
00221 using shards::getCellTopologyData;
00222
00223
00224 std::string
00225 eb_name = mesh_specs.ebName;
00226
00227
00228 Teuchos::ParameterList &
00229 material_model_sublist =
00230 matDB().getElementBlockSublist(eb_name,"Material Model");
00231
00232 std::string
00233 material_model_name = material_model_sublist.get<std::string>("Model Name");
00234
00235 TEUCHOS_TEST_FOR_EXCEPTION(
00236 material_model_name.length() == 0, std::logic_error,
00237 "A material model must be defined for block: " + eb_name);
00238
00239 #ifdef ALBANY_VERBOSE
00240 *out << "In SchwarzMultiscaleProblem::constructEvaluators" << '\n';
00241 *out << "element block name: " << eb_name << '\n';
00242 *out << "material model name: " << material_model_name << '\n';
00243 #endif
00244
00245
00246 RCP<CellTopology>
00247 composite_cell_type =
00248 rcp(new CellTopology(getCellTopologyData<shards::Tetrahedron<11> >()));
00249
00250 RCP<shards::CellTopology>
00251 cell_type = rcp(new CellTopology (&mesh_specs.ctd));
00252
00253
00254 bool
00255 is_composite = false;
00256
00257 bool const
00258 is_composite_block_present =
00259 matDB().isElementBlockParam(eb_name, "Use Composite Tet 10");
00260
00261 if (is_composite_block_present == true) {
00262 is_composite =
00263 matDB().getElementBlockParam<bool>(eb_name, "Use Composite Tet 10");
00264 }
00265
00266
00267 RCP<Intrepid::Basis<RealType, Intrepid::FieldContainer<RealType> > >
00268 intrepid_basis = Albany::getIntrepidBasis(mesh_specs.ctd, is_composite);
00269
00270 bool const
00271 is_composite_cell_type =
00272 is_composite &&
00273 mesh_specs.ctd.dimension == 3 &&
00274 mesh_specs.ctd.node_count == 10;
00275
00276 if (is_composite_cell_type == true) {
00277 cell_type = composite_cell_type;
00278 }
00279
00280 Intrepid::DefaultCubatureFactory<RealType>
00281 cubature_factory;
00282
00283 RCP <Intrepid::Cubature<RealType> >
00284 cubature = cubature_factory.create(*cell_type, mesh_specs.cubatureDegree);
00285
00286
00287 num_nodes_ = intrepid_basis->getCardinality();
00288 int const
00289 workset_size = mesh_specs.worksetSize;
00290
00291 num_dims_ = cubature->getDimension();
00292 num_pts_ = cubature->getNumPoints();
00293 num_vertices_ = num_nodes_;
00294
00295 #ifdef ALBANY_VERBOSE
00296 *out << "Field Dimensions: Workset=" << workset_size
00297 << ", Vertices= " << num_vertices_
00298 << ", Nodes= " << num_nodes_
00299 << ", QuadPts= " << num_pts_
00300 << ", Dim= " << num_dims_ << '\n';
00301 #endif
00302
00303
00304 RCP<Albany::Layouts>
00305 dl =
00306 rcp(
00307 new Albany::Layouts(
00308 workset_size, num_vertices_, num_nodes_, num_pts_, num_dims_
00309 )
00310 );
00311
00312 std::string const
00313 msg = "Data Layout Usage in Mechanics problems assume vecDim = num_dims_";
00314
00315 TEUCHOS_TEST_FOR_EXCEPTION(
00316 dl->vectorAndGradientLayoutsAreEquivalent == false,
00317 std::logic_error,
00318 msg);
00319
00320 Albany::EvaluatorUtils<EvalT, PHAL::AlbanyTraits>
00321 eu(dl);
00322
00323 int
00324 offset = 0;
00325
00326
00327 RCP<PHX::Evaluator<AlbanyTraits> > ev;
00328
00329
00330 {
00331 Teuchos::ArrayRCP<std::string>
00332 dof_names(1);
00333
00334 Teuchos::ArrayRCP<std::string>
00335 resid_names(1);
00336
00337 dof_names[0] = "Displacement";
00338 resid_names[0] = dof_names[0] + " Residual";
00339
00340 fm0.template registerEvaluator<EvalT>(
00341 eu.constructGatherSolutionEvaluator_noTransient(true, dof_names)
00342 );
00343
00344 fm0.template registerEvaluator<EvalT>(
00345 eu.constructGatherCoordinateVectorEvaluator()
00346 );
00347
00348 fm0.template registerEvaluator<EvalT>(
00349 eu.constructDOFVecInterpolationEvaluator(dof_names[0])
00350 );
00351
00352 fm0.template registerEvaluator<EvalT>(
00353 eu.constructDOFVecGradInterpolationEvaluator(dof_names[0])
00354 );
00355
00356 fm0.template registerEvaluator<EvalT>(
00357 eu.constructMapToPhysicalFrameEvaluator(cell_type, cubature)
00358 );
00359
00360 fm0.template registerEvaluator<EvalT>(
00361 eu.constructComputeBasisFunctionsEvaluator(
00362 cell_type, intrepid_basis, cubature
00363 )
00364 );
00365
00366 fm0.template registerEvaluator<EvalT>(
00367 eu.constructScatterResidualEvaluator(true, resid_names)
00368 );
00369
00370 offset += num_dims_;
00371 }
00372
00373
00374 LCM::FieldNameMap
00375 field_name_map(false);
00376
00377 RCP<std::map<std::string, std::string> >
00378 fnm = field_name_map.getMap();
00379
00380 std::string cauchy = (*fnm)["Cauchy_Stress"];
00381 std::string Fp = (*fnm)["Fp"];
00382 std::string eqps = (*fnm)["eqps"];
00383
00384 {
00385 RCP<ParameterList>
00386 p = rcp(new ParameterList("Time"));
00387 p->set<std::string>("Time Name", "Time");
00388 p->set<std::string>("Delta Time Name", "Delta Time");
00389 p->set<RCP<DataLayout> >("Workset Scalar Data Layout", dl->workset_scalar);
00390 p->set<RCP<ParamLib> >("Parameter Library", paramLib);
00391 p->set<bool>("Disable Transient", true);
00392 ev = rcp(new LCM::Time<EvalT,AlbanyTraits>(*p));
00393 fm0.template registerEvaluator<EvalT>(ev);
00394 p = state_mgr.registerStateVariable(
00395 "Time",
00396 dl->workset_scalar,
00397 dl->dummy,
00398 eb_name,
00399 "scalar",
00400 0.0,
00401 true
00402 );
00403 ev = rcp(new PHAL::SaveStateField<EvalT,AlbanyTraits>(*p));
00404 fm0.template registerEvaluator<EvalT>(ev);
00405 }
00406
00407 if (have_source_ == true) {
00408 RCP<ParameterList>
00409 p = rcp(new ParameterList);
00410 p->set<std::string>("Source Name", "Source");
00411 p->set<std::string>("Variable Name", "Displacement");
00412 p->set< RCP<DataLayout> >("QP Scalar Data Layout", dl->qp_scalar);
00413
00414 p->set<RCP<ParamLib> >("Parameter Library", paramLib);
00415 Teuchos::ParameterList &
00416 param_list = params->sublist("Source Functions");
00417 p->set<Teuchos::ParameterList*>("Parameter List", ¶m_list);
00418
00419 ev = rcp(new PHAL::Source<EvalT,AlbanyTraits>(*p));
00420 fm0.template registerEvaluator<EvalT>(ev);
00421 }
00422
00423 {
00424 RCP<ParameterList>
00425 p = rcp(new ParameterList("Constitutive Model Parameters"));
00426
00427 std::string const
00428 name = matDB().getElementBlockParam<std::string>(eb_name,"material");
00429
00430 Teuchos::ParameterList &
00431 param_list = matDB().getElementBlockSublist(eb_name, name);
00432
00433 p->set<Teuchos::ParameterList*>("Material Parameters", ¶m_list);
00434
00435 RCP<LCM::ConstitutiveModelParameters<EvalT,AlbanyTraits> >
00436 cmp_ev = rcp(
00437 new LCM::ConstitutiveModelParameters<EvalT, AlbanyTraits>(*p, dl)
00438 );
00439 fm0.template registerEvaluator<EvalT>(cmp_ev);
00440 }
00441
00442 {
00443 RCP<ParameterList>
00444 p = rcp(new ParameterList("Constitutive Model Interface"));
00445
00446 std::string const
00447 name = matDB().getElementBlockParam<std::string>(eb_name, "material");
00448
00449 Teuchos::ParameterList &
00450 param_list = matDB().getElementBlockSublist(eb_name, name);
00451
00452 param_list.set<RCP<std::map<std::string, std::string> > >("Name Map", fnm);
00453 p->set<Teuchos::ParameterList*>("Material Parameters", ¶m_list);
00454
00455 RCP<LCM::ConstitutiveModelInterface<EvalT,AlbanyTraits> >
00456 cmi_ev = rcp(
00457 new LCM::ConstitutiveModelInterface<EvalT, AlbanyTraits>(*p, dl)
00458 );
00459 fm0.template registerEvaluator<EvalT>(cmi_ev);
00460
00461
00462 for (int sv(0); sv < cmi_ev->getNumStateVars(); ++sv) {
00463 cmi_ev->fillStateVariableStruct(sv);
00464 p = state_mgr.registerStateVariable(
00465 cmi_ev->getName(),
00466 cmi_ev->getLayout(),
00467 dl->dummy,
00468 eb_name,
00469 cmi_ev->getInitType(),
00470 cmi_ev->getInitValue(),
00471 cmi_ev->getStateFlag(),
00472 cmi_ev->getOutputFlag()
00473 );
00474 ev = rcp(new PHAL::SaveStateField<EvalT,AlbanyTraits>(*p));
00475 fm0.template registerEvaluator<EvalT>(ev);
00476 }
00477 }
00478
00479
00480 {
00481 RCP<ParameterList>
00482 p = rcp(new ParameterList("Kinematics"));
00483
00484 std::string const
00485 wva_str = "Weighted Volume Average J";
00486
00487 bool const
00488 is_wva = matDB().isElementBlockParam(eb_name, wva_str);
00489
00490
00491 if (is_wva == true) {
00492 bool const
00493 ebp_wva = matDB().getElementBlockParam<bool>(eb_name, wva_str);
00494 p->set<bool>(wva_str, ebp_wva);
00495 }
00496
00497 std::string const
00498 asp_str = "Average J Stabilization Parameter";
00499
00500 bool const
00501 is_asp = matDB().isElementBlockParam(eb_name, asp_str);
00502
00503 if (is_asp == true) {
00504 bool const
00505 ebp_asp = matDB().getElementBlockParam<RealType>(eb_name, asp_str);
00506 p->set<RealType>(asp_str, ebp_asp);
00507 }
00508
00509
00510 bool have_strain(false), have_velocity_gradient(false);
00511
00512 std::string const
00513 str_str = "Strain Flag";
00514
00515 bool const
00516 is_str = matDB().isElementBlockParam(eb_name, str_str);
00517
00518 if (is_str == true) {
00519 bool const
00520 ebp_str = matDB().getElementBlockParam<bool>(eb_name, str_str);
00521 p->set<bool>(str_str, ebp_str);
00522
00523 if (ebp_str == true) {
00524 p->set<std::string>("Strain Name", "Strain");
00525 }
00526 }
00527
00528 std::string const
00529 vgf_str = "Velocity Gradient Flag";
00530
00531 bool const
00532 is_vgf = matDB().isElementBlockParam(eb_name, vgf_str);
00533
00534 if (is_vgf == true) {
00535 bool const
00536 ebp_vgf = matDB().getElementBlockParam<bool>(eb_name, vgf_str);
00537 p->set<bool>(vgf_str, ebp_vgf);
00538
00539 if (ebp_vgf == true) {
00540 p->set<std::string>("Velocity Gradient Name", "Velocity Gradient");
00541 }
00542 }
00543
00544
00545 p->set<std::string>("Weights Name","Weights");
00546 p->set<std::string>("Gradient QP Variable Name", "Displacement Gradient");
00547
00548
00549 p->set<std::string>("DefGrad Name", "F");
00550 p->set<std::string>("DetDefGrad Name", "J");
00551
00552 ev = rcp(new LCM::Kinematics<EvalT,AlbanyTraits>(*p, dl));
00553 fm0.template registerEvaluator<EvalT>(ev);
00554
00555
00556
00557 bool output_flag(false);
00558 if (matDB().isElementBlockParam(eb_name, "Output Deformation Gradient")) {
00559 output_flag = matDB().getElementBlockParam<bool>(
00560 eb_name,
00561 "Output Deformation Gradient"
00562 );
00563 }
00564
00565 p = state_mgr.registerStateVariable(
00566 "F",
00567 dl->qp_tensor,
00568 dl->dummy,
00569 eb_name,
00570 "identity",
00571 1.0,
00572 output_flag
00573 );
00574 ev = rcp(new PHAL::SaveStateField<EvalT,AlbanyTraits>(*p));
00575 fm0.template registerEvaluator<EvalT>(ev);
00576
00577
00578 output_flag = false;
00579
00580 if (matDB().isElementBlockParam(eb_name, "Output J")) {
00581 output_flag = matDB().getElementBlockParam<bool>(
00582 eb_name,
00583 "Output J"
00584 );
00585 }
00586
00587 if (output_flag == true) {
00588 p = state_mgr.registerStateVariable(
00589 "J",
00590 dl->qp_scalar,
00591 dl->dummy,
00592 eb_name,
00593 "scalar",
00594 1.0,
00595 true
00596 );
00597 ev = rcp(new PHAL::SaveStateField<EvalT,AlbanyTraits>(*p));
00598 fm0.template registerEvaluator<EvalT>(ev);
00599 }
00600
00601
00602 if (have_strain == true) {
00603 output_flag = false;
00604 if (matDB(). isElementBlockParam(eb_name, "Output Strain")) {
00605 output_flag =
00606 matDB().getElementBlockParam<bool>(eb_name, "Output Strain");
00607 }
00608
00609 p = state_mgr.registerStateVariable(
00610 "Strain",
00611 dl->qp_tensor,
00612 dl->dummy,
00613 eb_name,
00614 "scalar",
00615 0.0,
00616 output_flag
00617 );
00618 ev = rcp(new PHAL::SaveStateField<EvalT,AlbanyTraits>(*p));
00619 fm0.template registerEvaluator<EvalT>(ev);
00620 }
00621
00622
00623 if (have_velocity_gradient == true) {
00624 output_flag = false;
00625 if(matDB().isElementBlockParam(eb_name, "Output Velocity Gradient")) {
00626 output_flag = matDB().getElementBlockParam<bool>(
00627 eb_name,
00628 "Output Velocity Gradient"
00629 );
00630 }
00631
00632 p = state_mgr.registerStateVariable(
00633 "Velocity Gradient",
00634 dl->qp_tensor,
00635 dl->dummy,
00636 eb_name,
00637 "scalar",
00638 0.0,
00639 output_flag
00640 );
00641 ev = rcp(new PHAL::SaveStateField<EvalT,AlbanyTraits>(*p));
00642 fm0.template registerEvaluator<EvalT>(ev);
00643 }
00644
00645 }
00646
00647 {
00648 RCP<ParameterList>
00649 p = rcp(new ParameterList("Displacement Residual"));
00650
00651 p->set<std::string>("Stress Name", cauchy);
00652 p->set<std::string>("DefGrad Name", "F");
00653 p->set<std::string>("DetDefGrad Name", "J");
00654 p->set<std::string>("Weighted Gradient BF Name", "wGrad BF");
00655 p->set<std::string>("Weighted BF Name", "wBF");
00656
00657
00658 if (matDB().isElementBlockParam(eb_name,"Strain Flag")) {
00659 p->set<bool>("Strain Flag","Strain Flag");
00660 }
00661
00662 p->set<RCP<ParamLib> >("Parameter Library", paramLib);
00663
00664 p->set<std::string>("Residual Name", "Displacement Residual");
00665 ev = rcp(new LCM::MechanicsResidual<EvalT,AlbanyTraits>(*p,dl));
00666 fm0.template registerEvaluator<EvalT>(ev);
00667 }
00668
00669 Teuchos::RCP<const PHX::FieldTag>
00670 ret_tag = Teuchos::null;
00671
00672 if (fm_choice == Albany::BUILD_RESID_FM) {
00673 PHX::Tag<typename EvalT::ScalarT>
00674 res_tag("Scatter", dl->dummy);
00675 fm0.requireField<EvalT>(res_tag);
00676 ret_tag = res_tag.clone();
00677 }
00678 else if (fm_choice == Albany::BUILD_RESPONSE_FM) {
00679 Albany::ResponseUtilities<EvalT, PHAL::AlbanyTraits>
00680 respUtils(dl);
00681 ret_tag = respUtils.constructResponses(fm0, *response_list, state_mgr);
00682 }
00683
00684 return ret_tag;
00685 }
00686
00687 #endif // LCM_SchwarzMultiscaleProblem_hpp