22#include <yaml-cpp/yaml.h>
30 ((std::abs(a) < std::abs(b) ? std::abs(b) : std::abs(a)) * 1.0E-5);
34 std::cout <<
"Warning: We now require rectangle to be specified "
35 "by 3 dimensional coordinates of corner points. In "
36 "future, this will be strongly preferred.\n";
44 for (
size_t i=0; i<svec.size(); i++) {
46 if (i < svec.size() - 1)
54 std::string data_block_name,
56 std::vector<double> ¶ms,
57 std::pair<std::vector<std::string>, std::vector<std::string>> &complexInfo) {
60 std::cerr <<
"Error; Can not read geometry type in yaml data in block = "
61 << data_block_name <<
".\n";
64 name = data[
"Type"].as<std::string>();
66 if (name ==
"complex") {
68 if (data[
"Vec_Type"]) {
69 for (
auto f: data[
"Vec_Type"])
70 complexInfo.first.push_back(f.as<std::string>());
72 std::cerr <<
"Error: To define complex geometry, we require vector of "
73 "types in yaml data block = "
74 << data_block_name <<
"\n";
78 if (data[
"Vec_Flag"]) {
79 for (
auto f: data[
"Vec_Flag"])
80 complexInfo.second.push_back(f.as<std::string>());
82 std::cerr <<
"Error: To define complex geometry, we require vector of "
83 "flags in yaml data block = "
84 << data_block_name <<
"\n";
90 if (data[
"Parameters"]) {
91 for (
auto f : data[
"Parameters"])
92 params.push_back(f.as<
double>());
94 std::cerr <<
"Error: Parameters defining geometry is not present in data block = "
95 << data_block_name <<
".\n";
101 std::string data_block_name,
113 : d_inputFilename(filename),
114 d_createDefault(createDefault),
115 d_meshDeck_p(nullptr),
116 d_materialDeck_p(nullptr),
117 d_outputDeck_p(nullptr),
118 d_modelDeck_p(nullptr) {
123 <<
"Input: YAML input filename is empty and createDefault is true. "
124 "Default input decks will be created.\n";
126 std::cerr <<
"Error: YAML input filename is empty and createDefault is false. Exiting.\n";
155 return d_modelDeck_p->d_particleSimType ==
"Multi_Particle";
159 if (d_modelDeck_p->d_particleSimType ==
"Multi_Particle" or
160 d_modelDeck_p->d_particleSimType ==
"Single_Particle")
190 d_modelDeck_p = std::make_shared<inp::ModelDeck>();
192 if (d_inputFilename.empty() and d_createDefault)
195 YAML::Node config = YAML::LoadFile(d_inputFilename);
198 if (config[
"Model"][
"Dimension"])
199 d_modelDeck_p->d_dim = config[
"Model"][
"Dimension"].as<
size_t>();
201 std::cerr <<
"Error: Please specify the dimension.\n";
206 if (config[
"Model"][
"Discretization_Type"][
"Time"])
207 d_modelDeck_p->d_timeDiscretization =
208 config[
"Model"][
"Discretization_Type"][
"Time"].as<std::string>();
210 if (config[
"Model"][
"Discretization_Type"][
"Spatial"])
211 d_modelDeck_p->d_spatialDiscretization =
212 config[
"Model"][
"Discretization_Type"][
"Spatial"].as<std::string>();
215 if (d_modelDeck_p->d_timeDiscretization ==
"central_difference" or
216 d_modelDeck_p->d_timeDiscretization ==
"velocity_verlet")
217 d_modelDeck_p->d_simType =
"explicit";
219 if (config[
"Model"][
"Populate_ElementNodeConnectivity"])
220 d_modelDeck_p->d_populateElementNodeConnectivity =
true;
222 if (config[
"Model"][
"Quad_Approximation_Order"])
223 d_modelDeck_p->d_quadOrder = config[
"Model"][
"Quad_Approximation_Order"].as<
size_t>();
227 if (config[
"Model"][
"Particle_Sim_Type"])
228 d_modelDeck_p->d_particleSimType = config[
"Model"][
"Particle_Sim_Type"].as<std::string>();
231 if (config[
"Particle"])
232 d_modelDeck_p->d_particleSimType =
"Multi_Particle";
235 if (d_modelDeck_p->d_particleSimType !=
"Multi_Particle"
236 and d_modelDeck_p->d_particleSimType !=
"Single_Particle") {
237 std::cerr <<
"Error: Model->Particle_Sim_Type should be either Multi_Particle or Single_Particle.\n";
242 if (d_modelDeck_p->d_particleSimType !=
"Multi_Particle" && d_modelDeck_p->d_particleSimType !=
"Single_Particle") {
243 std::cerr <<
"Error: d_particleSimType = " << d_modelDeck_p->d_particleSimType
244 <<
" in Model Deck is invalid.\n";
250 if (config[
"Model"][
"Mesh_Size"])
251 d_modelDeck_p->d_h = config[
"Model"][
"Mesh_Size"].as<
double>();
252 if (config[
"Mesh"][
"Mesh_Size"])
253 d_modelDeck_p->d_h = config[
"Mesh"][
"Mesh_Size"].as<
double>();
255 if (config[
"Model"][
"Horizon"])
256 d_modelDeck_p->d_horizon = config[
"Model"][
"Horizon"].as<
double>();
258 if (config[
"Model"][
"Horizon_h_Ratio"]) {
259 d_modelDeck_p->d_rh = config[
"Model"][
"Horizon_h_Ratio"].as<
int>();
260 if (config[
"Model"][
"Mesh_Size"] or config[
"Mesh"][
"Mesh_Size"]) {
261 d_modelDeck_p->d_horizon = d_modelDeck_p->d_h * double(d_modelDeck_p->d_rh);
264 if (config[
"Model"][
"Horizon"])
266 d_modelDeck_p->d_horizon / double(d_modelDeck_p->d_rh);
271 if (config[
"Model"][
"Final_Time"])
272 d_modelDeck_p->d_tFinal = config[
"Model"][
"Final_Time"].as<
double>();
273 if (config[
"Model"][
"Time_Steps"])
274 d_modelDeck_p->d_Nt = config[
"Model"][
"Time_Steps"].as<
int>();
276 if (std::abs(d_modelDeck_p->d_tFinal) < 1.0E-10 or d_modelDeck_p->d_Nt <= 0) {
277 std::cerr <<
"Error: Check Final_Time and Time_Steps data.\n";
281 d_modelDeck_p->d_dt = d_modelDeck_p->d_tFinal / d_modelDeck_p->d_Nt;
284 if (config[
"Restart"])
285 d_modelDeck_p->d_isRestartActive =
true;
288 if (config[
"Model"][
"Seed"])
289 d_modelDeck_p->d_seed = config[
"Model"][
"Seed"].as<
int>();
293 d_particleDeck_p = std::make_shared<inp::ParticleDeck>();
295 if (d_inputFilename.empty() and d_createDefault)
298 YAML::Node config = YAML::LoadFile(d_inputFilename);
304 if (config[
"Container"][
"Geometry"]) {
305 auto ce = config[
"Container"][
"Geometry"];
308 "Container->Geometry",
309 d_particleDeck_p->d_contGeomData);
312 d_modelDeck_p->d_dim);
316 d_particleDeck_p->d_contGeomData.createNullGeomObject();
317 d_particleDeck_p->d_contGeomData.d_geom_p->d_tags.push_back(
"default");
325 if (!config[
"Zone"]) {
326 if (isMultiParticle()) {
328 <<
"Error: Zone information is not provided for Multi_Particle simulation type.\n";
333 n = config[
"Zone"][
"Zones"].as<
size_t>();
335 std::cerr <<
"Error: Require at least one zone to define particles.\n";
340 d_particleDeck_p->d_zoneVec.resize(n);
341 d_particleDeck_p->d_particleZones.resize(n);
342 d_particleDeck_p->d_zoneToParticleORWallDeck.resize(n);
345 for (
size_t z = 1; z <= n; z++) {
347 std::string read_zone =
"Zone_";
348 read_zone.append(std::to_string(z));
354 zone_data.d_zoneId = z - 1;
355 setZoneData({
"Zone", read_zone}, &zone_data);
358 d_particleDeck_p->d_zoneVec[z - 1] = zone_data;
364 particle_zone.d_zone = zone_data;
365 particle_zone.d_isWall =
false;
366 if (config[
"Zone"][read_zone][
"Is_Wall"])
367 particle_zone.d_isWall = config[
"Zone"][read_zone][
"Is_Wall"].as<
bool>();
369 setParticleData(read_zone, &particle_zone);
374 setZoneMeshDeck({
"Mesh", read_zone}, &(particle_zone.d_meshDeck));
381 particle_zone.d_particleGeomData.d_geom_p->d_tags)) {
385 if (particle_zone.d_meshDeck.d_createMesh) {
386 if (particle_zone.d_meshDeck.d_createMeshGeomData.d_geom_p ==
nullptr) {
387 std::cerr <<
"Error: While reading mesh data for the case of creating mesh using in-built functions, "
388 "the code expected to either get geometry details in the Mesh block or the "
389 "geometry details in the Particle block.But since particle geometry "
390 "itself is a copy of container geometry, we can not proceed with the code.\n";
395 particle_zone.d_meshDeck.d_createMeshGeomData.copyGeometry(particle_zone.d_particleGeomData,
396 d_modelDeck_p->d_dim);
397 particle_zone.d_particleGeomData.d_geom_p->d_tags.push_back(
"copy");
398 particle_zone.d_particleGeomData.d_geom_p->d_tags.push_back(
"copy_from_zone_mesh");
404 if (particle_zone.d_meshDeck.d_createMesh) {
405 if (particle_zone.d_meshDeck.d_createMeshGeomData.d_geom_p ==
nullptr) {
407 particle_zone.d_particleGeomData.copyGeometry(particle_zone.d_meshDeck.d_createMeshGeomData,
408 d_modelDeck_p->d_dim);
415 setZoneMaterialDeck({
"Material", read_zone}, &(particle_zone.d_matDeck),
419 d_particleDeck_p->d_particleZones[z - 1] = particle_zone;
422 d_particleDeck_p->d_zoneToParticleORWallDeck[z - 1] =
423 std::make_pair(particle_zone.d_isWall ?
"wall" :
"particle",
430 if (config[
"Neighbor"]) {
431 auto ne = config[
"Neighbor"];
432 if (ne[
"Update_Criteria"])
433 d_particleDeck_p->d_pNeighDeck.d_updateCriteria =
434 ne[
"Update_Criteria"].as<std::string>();
436 d_particleDeck_p->d_pNeighDeck.d_updateCriteria =
"simple_all";
438 if (ne[
"Search_Factor"])
439 d_particleDeck_p->d_pNeighDeck.d_sFactor =
440 ne[
"Search_Factor"].as<
double>();
442 d_particleDeck_p->d_pNeighDeck.d_sFactor = 1.;
444 if (ne[
"Search_Interval"])
445 d_particleDeck_p->d_pNeighDeck.d_neighUpdateInterval =
446 ne[
"Search_Interval"].as<
size_t>();
448 d_particleDeck_p->d_pNeighDeck.d_neighUpdateInterval = 1;
450 if (isMultiParticle()) {
451 std::cout <<
"Warning: Neighbor block is missing in input yaml file.\n";
459 if (config[
"Force_BC"]) {
460 if (config[
"Force_BC"][
"Gravity"]) {
462 d_particleDeck_p->d_gravityActive =
true;
464 auto gf = std::vector<double>(3, 0.);
466 for (
auto e : config[
"Force_BC"][
"Gravity"])
467 gf[gf_c++] = e.as<
double>();
469 d_particleDeck_p->d_gravity =
util::Point(gf[0], gf[1], gf[2]);
476 std::vector<std::string> vtags = {
"Displacement_BC",
"Force_BC"};
478 for (
const auto &tag : vtags) {
482 if (config[tag][
"Sets"])
483 nsets = config[tag][
"Sets"].as<
int>();
485 for (
size_t s = 1; s <= nsets; s++) {
488 std::string read_set =
"Set_";
489 read_set.append(std::to_string(s));
490 auto e = config[tag][read_set];
495 if (e[
"Selection_Type"])
496 bc_deck.d_selectionType = e[
"Selection_Type"].as<std::string>();
501 bc_deck.d_isRegionActive =
true;
503 bc_deck.d_selectionType =
"region";
505 if (e[
"Particle_List"])
506 bc_deck.d_selectionType +=
"_with_include_list";
508 if (e[
"Wall_List"]) {
509 std::cerr <<
"Error: We only accept 'Particle_List'.\n";
513 if (e[
"Particle_Exclude_List"])
514 bc_deck.d_selectionType +=
"_with_exclude_list";
517 bc_deck.d_isRegionActive =
false;
519 if (e[
"Particle_List"])
520 bc_deck.d_selectionType =
"particle";
522 if (e[
"Wall_List"]) {
523 std::cerr <<
"Error: We only accept 'Particle_List'.\n";
532 if (e[
"Region"][
"Geometry"]) {
534 auto ce = e[
"Region"][
"Geometry"];
536 readGeometry(ce, tag +
"->" + read_set +
"->Region->Geometry",
537 bc_deck.d_regionGeomData);
540 d_modelDeck_p->d_dim);
543 std::cerr <<
"Error: For region-based application of boundary condition, we require"
550 if (e[
"Particle_List"]) {
551 for (
auto f : e[
"Particle_List"])
552 bc_deck.d_pList.emplace_back(f.as<
size_t>());
556 if (e[
"Wall_List"]) {
557 std::cerr <<
"Error: We only accept 'Particle_List'.\n";
562 if (e[
"Particle_Exclude_List"]) {
563 for (
auto f : e[
"Particle_Exclude_List"])
564 bc_deck.d_pNotList.emplace_back(f.as<
size_t>());
568 for (
auto j : e[
"Direction"])
569 bc_deck.d_direction.push_back(j.as<
size_t>());
572 if (e[
"Time_Function"]) {
573 bc_deck.d_timeFnType = e[
"Time_Function"][
"Type"].as<std::string>();
574 if (e[
"Time_Function"][
"Parameters"])
575 for (
auto j : e[
"Time_Function"][
"Parameters"])
576 bc_deck.d_timeFnParams.push_back(j.as<
double>());
579 if (e[
"Spatial_Function"]) {
580 bc_deck.d_spatialFnType =
581 e[
"Spatial_Function"][
"Type"].as<std::string>();
582 if (e[
"Spatial_Function"][
"Parameters"])
583 for (
auto j : e[
"Spatial_Function"][
"Parameters"])
584 bc_deck.d_spatialFnParams.push_back(j.as<
double>());
589 if (tag ==
"Displacement_BC" && e[
"Zero_Displacement"])
590 bc_deck.d_isDisplacementZero = e[
"Zero_Displacement"].as<
bool>();
592 if (bc_deck.d_regionGeomData.d_geom_p ==
nullptr)
593 bc_deck.d_regionGeomData.createNullGeomObject();
596 if (tag ==
"Displacement_BC")
597 d_particleDeck_p->d_dispDeck.push_back(bc_deck);
599 d_particleDeck_p->d_forceDeck.push_back(bc_deck);
607 if (config[
"IC"][
"Constant_Velocity"]) {
609 d_particleDeck_p->d_icDeck.d_icActive =
true;
611 auto icv = std::vector<double>(3, 0.);
613 for (
auto e : config[
"IC"][
"Constant_Velocity"][
"Velocity_Vector"])
614 icv[icv_c++] = e.as<
double>();
616 d_particleDeck_p->d_icDeck.d_icVec =
util::Point(icv[0], icv[1], icv[2]);
619 d_particleDeck_p->d_icDeck.d_pList.clear();
620 if (isMultiParticle()) {
621 for (
auto e: config[
"IC"][
"Constant_Velocity"][
"Particle_List"])
622 d_particleDeck_p->d_icDeck.d_pList.push_back(e.as<
size_t>());
626 d_particleDeck_p->d_icDeck.d_pList.push_back(0);
634 if (config[
"Particle"][
"Test_Name"]) {
635 d_particleDeck_p->d_testName =
636 config[
"Particle"][
"Test_Name"].as<std::string>();
638 if (d_particleDeck_p->d_testName ==
"compressive_test") {
639 if (!config[
"Particle"][
"Compressive_Test"]) {
640 std::cerr <<
"Error: For compressive test, we require more "
641 "information such as wall id and wall force direction\n";
646 if (config[
"Particle"][
"Compressive_Test"][
"Wall_Id"]) {
647 std::cerr <<
"Error: We only accept 'Particle_Id' in 'config[Particle][Compressive_Test]'.\n";
650 d_particleDeck_p->d_particleIdCompressiveTest =
651 config[
"Particle"][
"Compressive_Test"][
"Particle_Id"].as<
size_t>();
653 if (config[
"Particle"][
"Compressive_Test"][
"Wall_Force_Direction"]) {
654 std::cerr <<
"Error: We only accept 'Particle_Force_Direction' in 'config[Particle][Compressive_Test]'.\n";
657 d_particleDeck_p->d_particleForceDirectionCompressiveTest =
658 config[
"Particle"][
"Compressive_Test"][
"Particle_Force_Direction"]
666 d_contactDeck_p = std::make_shared<inp::ContactDeck>();
668 if (d_inputFilename.empty() and d_createDefault)
671 YAML::Node config = YAML::LoadFile(d_inputFilename);
673 if (d_particleDeck_p ==
nullptr) {
674 std::cerr <<
"Error: Particle data must be read and populated before "
675 "reading contact data"
681 size_t n = d_particleDeck_p->d_zoneVec.size();
683 d_contactDeck_p->d_data.resize(n);
684 for (
size_t i = 0; i < n; i++)
685 d_contactDeck_p->d_data[i].resize(n);
687 if (!isMultiParticle()) {
691 for (
size_t z = 1; z <= n; z++) {
692 for (
size_t zz = z; zz <= n; zz++) {
693 std::string read_zone =
"Zone_" + std::to_string(z) + std::to_string(zz);
695 if (d_outputDeck_p->d_debug > 3)
696 std::cout <<
"Processing pair (z, zz) = (" << z <<
", " << zz <<
").\n";
698 auto e = config[
"Contact"][read_zone];
701 if (e[
"Copy_Contact_Data"]) {
704 std::vector<size_t> zone_pair;
705 for (
auto j : e[
"Copy_Contact_Data"])
706 zone_pair.push_back(j.as<
size_t>());
708 if (zone_pair.size() != 2) {
709 std::cerr <<
"Error: Copy_Contact_Data in Contact deck for zone pair "
710 << read_zone <<
" is invalid.\n";
716 if (zone_pair[0] > z or (zone_pair[0] == z and zone_pair[1] >= zz)) {
717 std::cerr <<
"Error: Can not copy the contact data for zone = " <<
718 read_zone <<
" as the pair of data = ("
719 << zone_pair[0] <<
", " << zone_pair[1]
720 <<
") required to copy have not "
726 d_contactDeck_p->d_data[zone_pair[0] - 1][zone_pair[1] - 1];
728 if (d_outputDeck_p->d_debug > 3) {
729 std::cout <<
"Processing pair (z, zz) = (" << z <<
", " << zz <<
"). "
730 <<
"Copying contact data from (n, m) = (" << zone_pair[0]
731 <<
", " << zone_pair[1] <<
").\n";
736 d_contactDeck_p->d_data[z - 1][zz - 1] = cd;
737 d_contactDeck_p->d_data[zz - 1][z - 1] = cd;
743 if (e[
"Contact_Radius_Factor"]) {
744 cd.d_contactR = e[
"Contact_Radius_Factor"].as<
double>();
745 cd.d_computeContactR =
true;
746 }
else if (e[
"Contact_Radius"]) {
747 cd.d_contactR = e[
"Contact_Radius"].as<
double>();
748 cd.d_computeContactR =
false;
753 cd.d_dampingOn = e[
"Damping_On"].as<
bool>();
755 if (e[
"Friction_On"])
756 cd.d_frictionOn = e[
"Friction_On"].as<
bool>();
760 bool v_max_found =
false;
761 bool delta_max_found =
false;
766 delta_max_found =
true;
768 if (v_max_found and delta_max_found) {
769 cd.d_vMax = e[
"V_Max"].as<
double>();
770 cd.d_deltaMax = e[
"Delta_Max"].as<
double>();
773 if (v_max_found and !delta_max_found) {
774 cd.d_vMax = e[
"V_Max"].as<
double>();
779 std::cerr <<
"Error: Need V_Max parameter for contact force. Either"
780 " provide V_Max (and/or Delta_Max) or provide Kn.\n"
781 <<
"Processing pair (z, zz) = (" << z <<
", " << zz <<
").\n"
782 <<
"Contact deck info\n"
788 cd.d_Kn = e[
"Kn"].as<
double>();
791 cd.d_vMax = std::sqrt(cd.d_Kn);
794 if (cd.d_dampingOn) {
796 cd.d_eps = e[
"Epsilon"].as<
double>();
798 std::cerr <<
"Error: Epsilon needed" << std::endl;
805 if (cd.d_dampingOn &&
util::isLess(cd.d_betanFactor, 1.0e-8))
806 cd.d_dampingOn =
false;
808 if (cd.d_frictionOn) {
809 if (e[
"Friction_Coeff"])
810 cd.d_mu = e[
"Friction_Coeff"].as<
double>();
812 std::cerr <<
"Error: Friction_Coeff needed" << std::endl;
820 cd.d_KnFactor = e[
"Kn_Factor"].as<
double>();
821 if (e[
"Beta_n_Factor"])
822 cd.d_betanFactor = e[
"Beta_n_Factor"].as<
double>();
825 cd.d_betanFactor = 0.;
828 d_contactDeck_p->d_data[z - 1][zz - 1] = cd;
829 d_contactDeck_p->d_data[zz - 1][z - 1] = cd;
836 d_restartDeck_p = std::make_shared<inp::RestartDeck>();
837 if (d_inputFilename.empty() and d_createDefault)
840 YAML::Node config = YAML::LoadFile(d_inputFilename);
843 if (config[
"Restart"]) {
844 if (config[
"Restart"][
"File"])
845 d_restartDeck_p->d_file = config[
"Restart"][
"File"].as<std::string>();
847 std::cerr <<
"Error: Please specify the file for restart.\n";
852 if (config[
"Restart"][
"Step"])
853 d_restartDeck_p->d_step = config[
"Restart"][
"Step"].as<
size_t>();
855 std::cerr <<
"Error: Please specify the time step from which to restart "
860 if (config[
"Restart"][
"Change_Reference_Free_Dofs"])
861 d_restartDeck_p->d_changeRefFreeDofs =
862 config[
"Restart"][
"Change_Reference_Free_Dofs"].as<
bool>();
867 d_meshDeck_p = std::make_shared<inp::MeshDeck>();
868 if (d_inputFilename.empty() and d_createDefault)
871 YAML::Node config = YAML::LoadFile(d_inputFilename);
874 if (config[
"Model"][
"Dimension"])
875 d_meshDeck_p->d_dim = config[
"Model"][
"Dimension"].as<
size_t>();
878 if (config[
"Model"][
"Discretization_Type"][
"Spatial"])
879 d_meshDeck_p->d_spatialDiscretization =
880 config[
"Model"][
"Discretization_Type"][
"Spatial"].as<std::string>();
882 if (config[
"Model"][
"Populate_ElementNodeConnectivity"])
883 d_meshDeck_p->d_populateElementNodeConnectivity =
true;
885 if (config[
"Model"][
"Quad_Approximation_Order"])
886 d_meshDeck_p->d_quadOrder = config[
"Model"][
"Quad_Approximation_Order"].as<
size_t>();
889 if (config[
"Mesh"][
"File"])
890 d_meshDeck_p->d_filename = config[
"Mesh"][
"File"].as<std::string>();
892 if (config[
"Mesh"][
"CreateMesh"])
893 d_meshDeck_p->d_createMesh = config[
"Mesh"][
"CreateMesh"].as<
bool>();
895 if (config[
"Mesh"][
"CreateMeshInfo"])
896 d_meshDeck_p->d_createMeshInfo = config[
"Mesh"][
"CreateMeshInfo"].as<std::string>();
898 if (d_modelDeck_p->d_h < 1.0E-12)
899 d_meshDeck_p->d_computeMeshSize =
true;
901 d_meshDeck_p->d_h = d_modelDeck_p->d_h;
904 if (d_meshDeck_p->d_filename.empty() and !d_meshDeck_p->d_createMesh){
905 std::cerr <<
"Error: Either specify mesh filename or provide Mesh->CreateMesh: true in input file.\n";
909 if (d_meshDeck_p->d_createMesh and d_meshDeck_p->d_h < 1.e-16) {
910 std::cerr <<
"Error: CreateMesh is set to true but mesh size (using Model->Mesh_Size or Mesh->Mesh_Size) is not specified.\n";
916 d_materialDeck_p = std::make_shared<inp::MaterialDeck>();
917 if (d_inputFilename.empty() and d_createDefault)
920 YAML::Node config = YAML::LoadFile(d_inputFilename);
922 auto e = config[
"Material"];
923 if (e[
"Is_Plane_Strain"])
924 d_materialDeck_p->d_isPlaneStrain = e[
"Is_Plane_Strain"].as<
bool>();
926 d_materialDeck_p->d_materialType = e[
"Type"].as<std::string>();
928 std::cerr <<
"Error: Please specify the material type.\n";
931 if (e[
"Compute_From_Classical"])
932 d_materialDeck_p->d_computeParamsFromElastic =
933 e[
"Compute_From_Classical"].as<
bool>();
935 d_materialDeck_p->d_matData.d_E = e[
"E"].as<
double>();
937 d_materialDeck_p->d_matData.d_G = e[
"G"].as<
double>();
939 d_materialDeck_p->d_matData.d_K = e[
"K"].as<
double>();
941 d_materialDeck_p->d_matData.d_lambda = e[
"Lambda"].as<
double>();
943 d_materialDeck_p->d_matData.d_mu = e[
"Mu"].as<
double>();
944 if (e[
"Poisson_Ratio"])
945 d_materialDeck_p->d_matData.d_nu = e[
"Poisson_Ratio"].as<
double>();
947 d_materialDeck_p->d_matData.d_Gc = e[
"Gc"].as<
double>();
949 d_materialDeck_p->d_matData.d_KIc = e[
"KIc"].as<
double>();
952 if (e[
"Bond_Potential"]) {
953 auto f = e[
"Bond_Potential"];
955 d_materialDeck_p->d_bondPotentialType = f[
"Type"].as<
size_t>();
956 if (f[
"Check_Sc_Factor"])
957 d_materialDeck_p->d_checkScFactor = f[
"Check_Sc_Factor"].as<
double>();
958 if (f[
"Irreversible_Bond_Fracture"])
959 d_materialDeck_p->d_irreversibleBondBreak =
960 f[
"Irreversible_Bond_Fracture"].as<
bool>();
962 for (
auto j : f[
"Parameters"])
963 d_materialDeck_p->d_bondPotentialParams.push_back(j.as<
double>());
967 if (e[
"State_Potential"]) {
968 auto f = e[
"State_Potential"];
970 d_materialDeck_p->d_statePotentialType = f[
"Type"].as<
size_t>();
971 if (f[
"Contribution_From_Broken_Bond"])
972 d_materialDeck_p->d_stateContributionFromBrokenBond =
973 f[
"Contribution_From_Broken_Bond"].as<
bool>();
975 for (
auto j : f[
"Parameters"])
976 d_materialDeck_p->d_statePotentialParams.push_back(j.as<
double>());
980 if (e[
"Influence_Function"]) {
981 auto f = e[
"Influence_Function"];
983 d_materialDeck_p->d_influenceFnType = f[
"Type"].as<
size_t>();
985 for (
auto j : f[
"Parameters"])
986 d_materialDeck_p->d_influenceFnParams.push_back(j.as<
double>());
991 d_materialDeck_p->d_density = e[
"Density"].as<
double>();
993 std::cerr <<
"Error: Please specify the density of the material.\n";
999 d_outputDeck_p = std::make_shared<inp::OutputDeck>();
1000 if (d_inputFilename.empty() and d_createDefault)
1003 YAML::Node config = YAML::LoadFile(d_inputFilename);
1005 if (config[
"Output"]) {
1006 auto e = config[
"Output"];
1007 if (e[
"File_Format"])
1008 d_outputDeck_p->d_outFormat = e[
"File_Format"].as<std::string>();
1010 d_outputDeck_p->d_path = e[
"Path"].as<std::string>();
1012 for (
auto f : e[
"Tags"])
1013 d_outputDeck_p->d_outTags.push_back(f.as<std::string>());
1015 if (e[
"Output_Interval"])
1016 d_outputDeck_p->d_dtOut = e[
"Output_Interval"].as<
size_t>();
1017 d_outputDeck_p->d_dtOutOld = d_outputDeck_p->d_dtOut;
1018 d_outputDeck_p->d_dtOutCriteria = d_outputDeck_p->d_dtOut;
1020 d_outputDeck_p->d_debug = e[
"Debug"].as<
size_t>();
1021 if (e[
"Perform_FE_Out"])
1022 d_outputDeck_p->d_performFEOut = e[
"Perform_FE_Out"].as<
bool>();
1023 if (e[
"Compress_Type"])
1024 d_outputDeck_p->d_compressType = e[
"Compress_Type"].as<std::string>();
1025 if (e[
"Output_Criteria"]) {
1026 if (e[
"Output_Criteria"][
"Type"])
1027 d_outputDeck_p->d_outCriteria =
1028 e[
"Output_Criteria"][
"Type"].as<std::string>();
1029 if (e[
"Output_Criteria"][
"New_Interval"])
1030 d_outputDeck_p->d_dtOutCriteria =
1031 e[
"Output_Criteria"][
"New_Interval"].as<
size_t>();
1032 if (e[
"Output_Criteria"][
"Parameters"]) {
1033 auto ps = e[
"Output_Criteria"][
"Parameters"];
1035 d_outputDeck_p->d_outCriteriaParams.emplace_back(p.as<
double>());
1039 if (e[
"Perform_Out"])
1040 d_outputDeck_p->d_performOut = e[
"Perform_Out"].as<
bool>();
1041 if (e[
"Test_Output_Interval"])
1042 d_outputDeck_p->d_dtTestOut = e[
"Test_Output_Interval"].as<
size_t>();
1044 d_outputDeck_p->d_tagPPFile = e[
"Tag_PP"].as<std::string>();
1051 YAML::Node config = YAML::LoadFile(d_inputFilename);
1053 auto e = config[s_config[0]];
1054 if (s_config.size() > 1) {
1055 if (s_config.size() == 2)
1056 e = config[s_config[0]][s_config[1]];
1057 else if (s_config.size() == 3)
1058 e = config[s_config[0]][s_config[1]][s_config[2]];
1062 std::cerr <<
"Error: Can not read material properties for given zone.\n";
1067 if (e[
"Copy_Material_Data"]) {
1070 auto copy_zone_id = e[
"Copy_Material_Data"].as<
size_t>();
1072 if (copy_zone_id >= zone_id) {
1073 std::cerr <<
"Error: Invalid zone id for Material deck corresponding to"
1074 " zone = " << zone_id <<
".\n";
1078 s_config[1] =
"Zone_" + std::to_string(copy_zone_id);
1081 if (config[s_config[0]][s_config[1]][
"Copy_Material_Data"]) {
1082 std::cerr <<
"Error: Tag " << s_config[0] <<
"->" << s_config[1]
1083 <<
" should not have tag Copy_Material_Data\n";
1087 setZoneMaterialDeck(s_config, m_deck, copy_zone_id);
1091 if (e[
"Is_Plane_Strain"])
1096 std::cerr <<
"Error: Please specify the material type.\n";
1099 if (e[
"Compute_From_Classical"])
1111 if (e[
"Poisson_Ratio"])
1119 if (e[
"Bond_Potential"]) {
1120 auto f = e[
"Bond_Potential"];
1123 if (f[
"Check_Sc_Factor"])
1125 if (f[
"Irreversible_Bond_Fracture"])
1127 f[
"Irreversible_Bond_Fracture"].as<
bool>();
1128 if (f[
"Parameters"])
1129 for (
auto j : f[
"Parameters"])
1134 if (e[
"State_Potential"]) {
1135 auto f = e[
"State_Potential"];
1138 if (f[
"Contribution_From_Broken_Bond"])
1140 f[
"Contribution_From_Broken_Bond"].as<
bool>();
1141 if (f[
"Parameters"])
1142 for (
auto j : f[
"Parameters"])
1147 if (e[
"Influence_Function"]) {
1148 auto f = e[
"Influence_Function"];
1151 if (f[
"Parameters"])
1152 for (
auto j : f[
"Parameters"])
1158 m_deck->
d_density = e[
"Density"].as<
double>();
1160 std::cerr <<
"Error: Please specify the density of the material.\n";
1166 m_deck->
d_horizon = e[
"Horizon"].as<
double>();
1169 if (e[
"Horizon_Mesh_Ratio"])
1178 YAML::Node config = YAML::LoadFile(d_inputFilename);
1180 auto e = config[s_config[0]];
1181 if (s_config.size() > 1) {
1182 if (s_config.size() == 2)
1183 e = config[s_config[0]][s_config[1]];
1184 else if (s_config.size() == 3)
1185 e = config[s_config[0]][s_config[1]][s_config[2]];
1189 std::cerr <<
"Error: Can not read mesh properties for given zone.\n";
1194 mesh_deck->
d_dim = config[
"Model"][
"Dimension"].as<
size_t>();
1197 if (config[
"Model"][
"Discretization_Type"][
"Spatial"])
1199 config[
"Model"][
"Discretization_Type"][
"Spatial"].as<std::string>();
1203 mesh_deck->
d_filename = e[
"File"].as<std::string>();
1205 if (e[
"CreateMesh"]) {
1206 if (e[
"CreateMesh"][
"Flag"])
1207 mesh_deck->
d_createMesh = e[
"CreateMesh"][
"Flag"].as<
bool>();
1209 if (e[
"CreateMesh"][
"Info"])
1213 if (e[
"CreateMesh"][
"Geometry"]) {
1215 readGeometry(e[
"CreateMesh"][
"Geometry"],
1216 "Mesh->CreateMesh->Geometry",
1220 d_modelDeck_p->d_dim);
1224 if (e[
"Mesh_Size"]) {
1225 mesh_deck->
d_h = e[
"Mesh_Size"].as<
double>();
1232 std::cerr <<
"Error: Either specify mesh filename or provide Mesh->CreateMesh: true in input file.\n";
1237 std::cerr <<
"Error: CreateMesh is set to true but mesh size (using Model->Mesh_Size or Mesh->Mesh_Size) is not specified.\n";
1247 YAML::Node config = YAML::LoadFile(d_inputFilename);
1248 auto e = config[s_config[0]];
1249 if (s_config.size() > 1)
1250 e = config[s_config[0]][s_config[1]];
1251 if (s_config.size() > 2)
1252 e = config[s_config[0]][s_config[1]][s_config[2]];
1264 readGeometry(e, stringVecSerial(s_config), zone_data->
d_zoneGeomData);
1267 d_modelDeck_p->d_dim,
1271 this->d_particleDeck_p->d_contGeomData.copyGeometry(zone_data->
d_zoneGeomData,
1272 d_modelDeck_p->d_dim);
1281 YAML::Node config = YAML::LoadFile(d_inputFilename);
1283 auto pe = config[
"Particle"][string_zone];
1287 auto wall_pe = config[
"Particle"][string_zone];
1289 std::cerr <<
"Error: For this particle/wall in zone = " << string_zone
1290 <<
" , neither config['Particle'] "
1291 "nor config['Wall'] exist in input file.\n";
1295 std::cout <<
"Warning: In future, for wall, separate config['Wall'] "
1296 "will not be used.\n";
1305 if (pe[
"All_Dofs_Constrained"])
1309 if (pe[
"Create_Particle_Using_ParticleZone_GeomObject"])
1311 = pe[
"Create_Particle_Using_ParticleZone_GeomObject"].as<
bool>();
1327 d_modelDeck_p->d_dim);
1330 if (pe[
"Near_Bd_Nodes_Tol"])
1332 pe[
"Near_Bd_Nodes_Tol"].as<
double>();
1338 this->d_particleDeck_p->d_contGeomData.copyGeometry(particle_data->
d_particleGeomData,
1339 d_modelDeck_p->d_dim);
1344 std::cerr <<
"Error: Particle/wall details for zone = " << string_zone
1345 <<
"is not provided.\n";
1353 auto re = config[
"Mesh"][string_zone][
"Reference_Particle"];
1356 readGeometry(re,
"Particle->" + string_zone +
"->Reference_Particle",
1360 d_modelDeck_p->d_dim);
1365 d_modelDeck_p->d_dim);
1374 if (config[
"Particle_Generation"][
"From_File"]) {
1378 config[
"Particle_Generation"][
"From_File"].as<std::string>();
1380 if (config[
"Particle_Generation"][
"File_Data_Type"]) {
1382 config[
"Particle_Generation"][
"File_Data_Type"].as<std::string>();
1387 std::cerr <<
"Error: Particle_Generation->From_File block is not provided"
1388 ". Can not generate particles for dem simulation. "
1389 "Terminating the simulation.\n";
1394 particle_data->
d_genMethod =
"Create_Particle_Using_ParticleZone_GeomObject";
void createGeomObject(const std::string &geom_type, const std::vector< double > ¶ms, const std::vector< std::string > &vec_type, const std::vector< std::string > &vec_flag, std::shared_ptr< util::geometry::GeomObject > &obj, const size_t &dim, bool perform_check=true)
bool isTagInList(const std::string &tag, const std::vector< std::string > &tags)
Returns true if tag is found in the list of tags.
bool isLess(const double &a, const double &b)
Returns true if a < b.
double d_mu
Lame second parameter.
double d_KIc
Critical stress intensity factor.
double d_lambda
Lame first parameter.
double d_nu
Poisson's ratio.
double d_G
Shear modulus or Lame second parameter.
double d_E
Young's elastic modulus.
double d_Gc
Critical energy release rate.
Structure to read and store material related data.
bool d_isPlaneStrain
Indicates if the 2-d simulation is of plane-strain type (thick material) or plane-stress type (thin m...
double d_density
Density of material.
size_t d_bondPotentialType
Type of pairwise (bond-based) potential.
double d_horizonMeshRatio
Horizon to mesh ratio.
size_t d_influenceFnType
Type of influence function.
std::vector< double > d_bondPotentialParams
List of parameters for pairwise potential.
std::string d_materialType
Material type.
double d_horizon
Horizon for peridynamic interaction.
bool d_stateContributionFromBrokenBond
Flag for contribution to hydrostatic force from the broken bond.
bool d_computeParamsFromElastic
Compute Peridynamic material properties from elastic properties.
inp::MatData d_matData
List of elastic and fracture properties.
std::vector< double > d_influenceFnParams
List of parameters for influence function.
size_t d_statePotentialType
Type of hydrostatic (state-based) potential.
std::vector< double > d_statePotentialParams
List of parameters for hydrostatic potential.
bool d_irreversibleBondBreak
Flag for irreversible breaking of bonds.
double d_checkScFactor
Factor to check if bond is broken.
Structure to read and store mesh related input data.
std::string d_spatialDiscretization
Tag for spatial discretization.
bool d_computeMeshSize
Flag which indicates if mesh size is to be computed.
bool d_createMesh
Specify if we create mesh using in-built gmsh or in-built routine for uniform discretization of recta...
std::string d_createMeshInfo
Information that will be used when creating a mesh using in-built routines.
std::string d_filename
Filename to read mesh data.
util::geometry::GeomData d_createMeshGeomData
Information that will be used when creating a mesh using in-built routines.
User-input data for particle neighbor search.
User-input data for particle zone.
bool d_allDofsConstrained
Specify if all dofs are constrained.
util::geometry::GeomData d_refParticleGeomData
Geometry of details of reference particle.
util::geometry::GeomData d_particleGeomData
Geometry of details of particle.
bool d_createParticleUsingParticleZoneGeomObject
Specify if the particle should be created using the particle geometry in the zone data and mesh file....
bool d_isWall
Is this particle actually a wall?
std::string d_particleFileDataType
Specify what data to be expected in the particle file e.g.
double d_nearBdNodesTol
Specify how deep we search for nodes near boundary for contact calculations.
std::string d_particleFile
Read particle from a file.
std::string d_genMethod
Particle generation method.
User-input data for zones.
util::geometry::GeomData d_zoneGeomData
Zone geometry data.
A structure to represent 3d vectors.
Input data for geometrical objects.
void copyGeometry(GeomData &z, size_t dim)
Copies the geometry details.
std::shared_ptr< util::geometry::GeomObject > d_geom_p
Zone geometry.
std::pair< std::vector< std::string >, std::vector< std::string > > d_geomComplexInfo
Zone geometry info if it is a complex type.
std::string d_geomName
Zone type.
std::vector< double > d_geomParams
Zone parameters.