17 const std::vector<double> ¶ms,
18 const std::vector<size_t> &num_params_needed) {
20 std::ostringstream oss;
22 oss <<
"Error: Number of parameters needed to create geometry = "
23 << geom_type <<
" are "
25 <<
". But the number of parameters provided are "
27 <<
" and the parameters are "
38 if (geom_type ==
"line")
40 else if (geom_type ==
"triangle")
42 else if (geom_type ==
"square")
44 else if (geom_type ==
"rectangle")
46 else if (geom_type ==
"hexagon")
48 else if (geom_type ==
"drum2d")
50 else if (geom_type ==
"cube")
52 else if (geom_type ==
"cuboid")
54 else if (geom_type ==
"circle")
56 else if (geom_type ==
"sphere")
58 else if (geom_type ==
"cylinder")
60 else if (geom_type ==
"angled_rectangle")
62 else if (geom_type ==
"angled_cuboid")
64 else if (geom_type ==
"rectangle_minus_rectangle")
66 else if (geom_type ==
"cuboid_minus_cuboid")
69 std::cerr <<
"Error: Invalid geometry type: " << geom_type << std::endl;
81 std::string geom_type,
82 std::vector<std::string> vec_type) {
85 for (
const auto &s: vec_type) {
89 num_params += nps[nps.size() - 1];
91 std::cerr <<
"Error: Geometry type = " << s
92 <<
" has zero number of parameters required. \n";
96 return n == num_params;
106 std::string geom_type,
107 std::vector<std::string> vec_type) {
115 const std::vector<double> ¶ms,
116 const std::vector<std::string> &vec_type,
117 const std::vector<std::string> &vec_flag,
118 std::shared_ptr<util::geometry::GeomObject> &obj,
120 bool perform_check) {
124 std::vector<std::string> no_default_obj = {
"cylinder",
"complex",
125 "rectangle_minus_rectangle",
126 "cuboid_minus_cuboid"};
129 if (type !=
"complex")
135 std::ostringstream oss;
137 oss <<
"Error: Data maybe invalid. Can not create geometrical object: "
146 std::cerr << oss.str();
152 if (type ==
"circle") {
156 obj = std::make_shared<util::geometry::Circle>(
157 params[0],
util::Point(params[1], params[2], params[3]));
160 if (params.size() < 1) {
162 std::cerr <<
"Error: need at least " << 1
163 <<
" parameters for creating circle. "
164 "Number of params provided = "
172 obj = std::make_shared<util::geometry::Circle>(params[0],
176 else if (type ==
"rectangle") {
180 obj = std::make_shared<util::geometry::Rectangle>(
181 params[0], params[1],
185 if (params.size() != 6 or params.size() != 5) {
187 std::cerr <<
"Error: need either 5 or 6"
188 <<
" parameters for creating Rectangle. "
189 "Number of params provided = "
197 if (params.size() == 6)
198 obj = std::make_shared<util::geometry::Rectangle>(
201 else if (params.size() == 5)
202 obj = std::make_shared<util::geometry::Rectangle>(
203 params[0], params[1],
207 else if (type ==
"square") {
211 obj = std::make_shared<util::geometry::Square>(
216 if (params.size() != 6) {
218 std::cerr <<
"Error: need " << 6
219 <<
" parameters for creating Square. "
220 "Number of params provided = "
228 obj = std::make_shared<util::geometry::Square>(
233 else if (type ==
"triangle") {
237 obj = std::make_shared<util::geometry::Triangle>(
238 params[0],
util::Point(params[1], params[2], params[3]),
242 if (params.size() != 4) {
244 std::cerr <<
"Error: need at least " << 4
245 <<
" parameters for creating triangle. "
246 "Number of params provided = "
254 obj = std::make_shared<util::geometry::Triangle>(
255 params[0],
util::Point(params[1], params[2], params[3]));
258 else if (type ==
"hexagon") {
262 obj = std::make_shared<util::geometry::Hexagon>(
263 params[0],
util::Point(params[1], params[2], params[3]),
267 if (params.size() != 4) {
269 std::cerr <<
"Error: need at least " << 4
270 <<
" parameters for creating hexagon. "
271 "Number of params provided = "
279 obj = std::make_shared<util::geometry::Hexagon>(
280 params[0],
util::Point(params[1], params[2], params[3]));
283 else if (type ==
"drum2d") {
287 obj = std::make_shared<util::geometry::Drum2D>(
288 params[0], params[1],
293 if (params.size() < 5) {
295 std::cerr <<
"Error: need at least " << 5
296 <<
" parameters for creating drum2d. "
297 "Number of params provided = "
305 obj = std::make_shared<util::geometry::Drum2D>(
306 params[0], params[1],
310 else if (type ==
"sphere") {
314 obj = std::make_shared<util::geometry::Sphere>(
315 params[0],
util::Point(params[1], params[2], params[3]));
318 if (params.size() < 1) {
320 std::cerr <<
"Error: need at least " << 1
321 <<
" parameters for creating sphere. "
322 "Number of params provided = "
330 obj = std::make_shared<util::geometry::Sphere>(params[0],
334 else if (type ==
"cuboid") {
338 obj = std::make_shared<util::geometry::Cuboid>(
339 params[0], params[1], params[2],
342 std::cerr <<
"Error: need at least " << 6
343 <<
" parameters for creating cuboid. "
344 "Number of params provided = "
351 else if (type ==
"cube") {
355 obj = std::make_shared<util::geometry::Cube>(
360 if (params.size() < 6) {
362 std::cerr <<
"Error: need " << 6
363 <<
" parameters for creating Cube. "
364 "Number of params provided = "
372 obj = std::make_shared<util::geometry::Cube>(
377 else if (type ==
"cylinder") {
381 obj = std::make_shared<util::geometry::Cylinder>(
382 params[0],
util::Point(params[1], params[2], params[3]),
385 std::cerr <<
"Error: need at least " << 7
386 <<
" parameters for creating Cylinder. "
387 "Number of params provided = "
394 else if (type ==
"rectangle_minus_rectangle") {
408 obj = std::make_shared<util::geometry::AnnulusGeomObject>
411 std::cerr <<
"Error: need at least " << 12
412 <<
" parameters for creating rectangle_minus_rectangle. "
413 "Number of params provided = "
420 else if (type ==
"cuboid_minus_cuboid") {
435 obj = std::make_shared<util::geometry::AnnulusGeomObject>
438 std::cerr <<
"Error: need at least " << 12
439 <<
" parameters for creating cuboid_minus_cuboid. "
440 "Number of params provided = "
447 else if (type ==
"complex") {
451 std::vector<std::shared_ptr<util::geometry::GeomObject>> vec_obj(
454 size_t param_start = 0;
455 for (
size_t i = 0; i < vec_type.size(); i++) {
456 auto geom_type = vec_type[i];
457 auto geom_flag = vec_flag[i];
461 auto p1 = params.begin() + param_start;
462 auto p2 = params.begin() + param_start + num_params;
463 auto geom_param = std::vector<double>(p1, p2);
467 std::vector<std::string>(), vec_obj[i], dim);
469 param_start += num_params;
474 obj = std::make_shared<util::geometry::ComplexGeomObject>(vec_obj,
479 std::cerr <<
"Error: Not enough parameters for creating complex. "
480 "Number of params provided = "
490 const std::vector<double> ¶ms,
491 const std::vector<std::string> &vec_type,
492 const std::vector<std::string> &vec_flag,
493 std::shared_ptr<util::geometry::GeomObject> &obj,
495 bool perform_check) {
497 std::vector<size_t> num_params_needed;
499 if (geom_type ==
"line") {
501 num_params_needed = {1, 4, 6};
503 for (
auto n: num_params_needed) {
504 if (params.size() == n) {
506 obj = std::make_shared<util::geometry::Line>(params[0]);
509 obj = std::make_shared<util::geometry::Line>(params[0],
517 obj = std::make_shared<util::geometry::Line>(
526 else if (geom_type ==
"triangle") {
528 num_params_needed = {1, 4, 7};
530 for (
auto n: num_params_needed) {
531 if (params.size() == n) {
533 obj = std::make_shared<util::geometry::Triangle>(params[0]);
536 obj = std::make_shared<util::geometry::Triangle>(
542 obj = std::make_shared<util::geometry::Triangle>(
552 else if (geom_type ==
"square") {
554 num_params_needed = {1, 4, 6};
556 for (
auto n: num_params_needed) {
557 if (params.size() == n) {
559 obj = std::make_shared<util::geometry::Square>(params[0]);
562 obj = std::make_shared<util::geometry::Square>(params[0],
569 obj = std::make_shared<util::geometry::Square>(
577 else if (geom_type ==
"rectangle") {
579 num_params_needed = {2, 5, 6};
581 for (
auto n: num_params_needed) {
582 if (params.size() == n) {
584 obj = std::make_shared<util::geometry::Rectangle>(params[0],
588 obj = std::make_shared<util::geometry::Rectangle>(
589 params[0], params[1],
593 obj = std::make_shared<util::geometry::Rectangle>(
601 else if (geom_type ==
"hexagon") {
603 num_params_needed = {1, 4, 7};
605 for (
auto n: num_params_needed) {
606 if (params.size() == n) {
608 obj = std::make_shared<util::geometry::Hexagon>(params[0]);
611 obj = std::make_shared<util::geometry::Hexagon>(
612 params[0],
util::Point(params[2], params[3], params[4]));
615 obj = std::make_shared<util::geometry::Hexagon>(
624 else if (geom_type ==
"drum2d") {
626 num_params_needed = {2, 5, 8};
628 for (
auto n: num_params_needed) {
629 if (params.size() == n) {
631 obj = std::make_shared<util::geometry::Drum2D>(
632 params[0], params[1]);
635 obj = std::make_shared<util::geometry::Drum2D>(
636 params[0], params[1],
640 obj = std::make_shared<util::geometry::Drum2D>(
641 params[0], params[1],
649 else if (geom_type ==
"cube") {
651 num_params_needed = {1, 4, 6};
653 for (
auto n: num_params_needed) {
654 if (params.size() == n) {
656 obj = std::make_shared<util::geometry::Cube>(params[0]);
659 obj = std::make_shared<util::geometry::Cube>(
664 obj = std::make_shared<util::geometry::Cube>(
672 else if (geom_type ==
"cuboid") {
674 num_params_needed = {3, 6};
676 for (
auto n: num_params_needed) {
677 if (params.size() == n) {
679 obj = std::make_shared<util::geometry::Cuboid>(
680 params[0], params[1], params[2]);
683 obj = std::make_shared<util::geometry::Cuboid>(
691 else if (geom_type ==
"circle") {
693 num_params_needed = {1, 4};
695 for (
auto n: num_params_needed) {
696 if (params.size() == n) {
698 obj = std::make_shared<util::geometry::Circle>(params[0]);
701 obj = std::make_shared<util::geometry::Circle>(
709 else if (geom_type ==
"sphere") {
711 num_params_needed = {1, 4};
713 for (
auto n: num_params_needed) {
714 if (params.size() == n) {
716 obj = std::make_shared<util::geometry::Sphere>(params[0]);
719 obj = std::make_shared<util::geometry::Sphere>(
727 else if (geom_type ==
"cylinder") {
729 num_params_needed = {7, 8};
731 for (
auto n: num_params_needed) {
732 if (params.size() == n) {
734 obj = std::make_shared<util::geometry::Cylinder>(
740 obj = std::make_shared<util::geometry::Cylinder>(
741 params[0], params[1],
749 else if (geom_type ==
"angled_rectangle") {
751 num_params_needed = {6};
753 for (
auto n: num_params_needed) {
754 if (params.size() == n) {
756 obj = std::make_shared<util::geometry::Rectangle>(
765 else if (geom_type ==
"angled_cuboid") {
767 num_params_needed = {6};
769 for (
auto n: num_params_needed) {
770 if (params.size() == n) {
772 obj = std::make_shared<util::geometry::Cuboid>(
781 else if (geom_type ==
"rectangle_minus_rectangle") {
783 num_params_needed = {12};
785 for (
auto n: num_params_needed) {
786 if (params.size() == n) {
796 obj = std::make_shared<util::geometry::AnnulusGeomObject>
804 else if (geom_type ==
"cuboid_minus_cuboid") {
806 num_params_needed = {12};
808 for (
auto n: num_params_needed) {
809 if (params.size() == n) {
819 obj = std::make_shared<util::geometry::AnnulusGeomObject>
827 else if (geom_type ==
"complex") {
835 num_params_needed = {0};
836 std::vector<size_t> params_level(vec_type.size());
837 for (
size_t i = 0; i < vec_type.size(); i++) {
842 params_level[i] = nps[nps.size() - 1];
844 std::cerr <<
"Error: Geometry type = " << vec_type[i]
845 <<
" has zero number of parameters required. \n";
852 num_params_needed[0] += params_level[i];
855 std::vector<std::shared_ptr<util::geometry::GeomObject>> objs(vec_type.size());
856 std::vector<std::string> obj_flags(vec_type.size());
858 if (params.size() == num_params_needed[0]) {
861 size_t param_start = 0;
862 for (
size_t i = 0; i < vec_type.size(); i++) {
864 auto geom_type_temp = vec_type[i];
865 auto geom_flag_temp = vec_flag[i];
867 std::vector<std::string> vec_type_temp;
868 std::vector<std::string> vec_flag_temp;
871 std::vector<double> params_temp;
872 for (
size_t j=0; j<params_level[i]; j++)
873 params_temp.push_back(params[j + param_start]);
876 obj_flags[i] = vec_flag[i];
878 geom_type_temp, params_temp, vec_type_temp, vec_flag_temp,
879 objs[i], dim, perform_check);
881 param_start += params_level[i];
885 obj = std::make_shared<util::geometry::ComplexGeomObject>(objs, obj_flags, dim);
891 std::cerr <<
"Error: Invalid geometry type: " << geom_type << std::endl;
896 std::cerr <<
printErrMsg(geom_type, params, num_params_needed);
902 bool perform_check) {
907 geomData.
d_geom_p, dim, perform_check);
915 if (d_geom_p->d_name ==
"null") {
917 std::make_shared<util::geometry::NullGeomObject>(
918 d_geom_p->d_description);
919 }
else if (d_geom_p->d_name.empty()) {
921 std::make_shared<util::geometry::GeomObject>(
922 d_geom_p->d_name, d_geom_p->d_description);
929 std::vector<double> ¶ms,
930 std::pair<std::vector<std::string>, std::vector<std::string>> &complexInfo,
931 std::shared_ptr<util::geometry::GeomObject> &geom,
934 params = d_geomParams;
935 complexInfo = d_geomComplexInfo;
937 if (d_geom_p->d_name ==
"null") {
939 std::make_shared<util::geometry::NullGeomObject>(
940 d_geom_p->d_description);
941 }
else if (d_geom_p->d_name.empty()) {
943 std::make_shared<util::geometry::GeomObject>(
944 d_geom_p->d_name, d_geom_p->d_description);
std::string printErrMsg(const std::string &geom_type, const std::vector< double > ¶ms, const std::vector< size_t > &num_params_needed)
std::string printErrMsg(const std::string &geom_type, const std::vector< double > ¶ms, const std::vector< size_t > &num_params_needed)
bool isNumberOfParamForComplexGeometryValid(size_t n, std::string geom_type, std::vector< std::string > vec_type)
Ascertain if number of parameters are correct for the given geometry.
bool isNumberOfParamForGeometryValid(size_t n, std::string geom_type)
Ascertain if number of parameters are correct for the given geometry.
std::vector< size_t > getNumParamsRequired(std::string geom_type)
Get num params required for creation of object.
bool checkParamForGeometry(size_t n, std::string geom_type)
Check parameter data for validity.
void createGeomObjectOld(const std::string &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)
Create geometrical object from the given data.
bool checkParamForComplexGeometry(size_t n, std::string geom_type, std::vector< std::string > vec_type)
Check parameter data for validity.
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)
std::string printStr(const T &msg, int nt=print_default_tab)
Returns formatted string for output.
bool isInList(const T &i, const std::vector< T > &list)
Find if data is in the list.
bool isTagInList(const std::string &tag, const std::vector< std::string > &tags)
Returns true if tag is found in the list of tags.
Collection of methods useful in simulation.
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.