19 if (!args.contains(
"common"))
22 const std::string common_params_path =
resolve_path(args[
"common"], args[
"root_path"]);
24 if (common_params_path.empty())
27 std::ifstream file(common_params_path);
32 file >> common_params;
36 const bool has_root_path = common_params.contains(
"root_path");
38 common_params[
"root_path"] =
resolve_path(common_params[
"root_path"], common_params_path);
40 common_params[
"root_path"] = common_params_path;
47 args[
"root_path"] = common_params[
"root_path"];
50 if (args.contains(
"patch"))
52 patch = args[
"patch"];
56 common_params.merge_patch(args);
58 common_params = common_params.patch(patch);
66 if (!args.contains(
"boundary_conditions"))
69 json &bcs = args[
"boundary_conditions"];
70 if (!bcs.contains(
"dirichlet_boundary") || !bcs[
"dirichlet_boundary"].is_array())
73 const json root_path = args.contains(
"root_path") ? args[
"root_path"] :
json(
"");
75 json expanded = json::array();
76 for (
const auto &entry : bcs[
"dirichlet_boundary"])
78 if (entry.is_string())
81 if (std::filesystem::path(path).extension() ==
".json")
83 std::ifstream file(path);
92 catch (
const std::exception &e)
98 if (!sidecar.is_array())
102 for (
const auto &e : sidecar)
105 expanded.push_back(jse.inject_defaults(filled, rules));
110 expanded.push_back(entry);
112 bcs[
"dirichlet_boundary"] = expanded;
117 std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
119 if (jr.is_array() && jr.empty())
121 return Eigen::Matrix3d::Identity(3, 3);
128 assert(mode.size() == 1);
129 int i = mode[0] -
'x';
130 assert(i >= 0 && i < 3);
131 r[i] = jr.get<
double>();
135 assert(jr.is_array());
139 if (mode ==
"axis_angle")
141 assert(r.size() == 4);
143 Eigen::Vector3d axis = r.tail<3>().normalized();
144 return Eigen::AngleAxisd(angle, axis).toRotationMatrix();
147 if (mode ==
"quaternion")
149 assert(r.size() == 4);
150 Eigen::Vector4d q = r.normalized();
151 return Eigen::Quaterniond(q).toRotationMatrix();
157 if (mode ==
"rotation_vector")
159 assert(r.size() == 3);
160 double angle = r.norm();
163 return Eigen::AngleAxisd(angle, r / angle).toRotationMatrix();
167 return Eigen::Matrix3d::Identity();
171 Eigen::Matrix3d R = Eigen::Matrix3d::Identity();
173 for (
int i = 0; i < mode.size(); i++)
175 int j = mode[i] -
'x';
176 assert(j >= 0 && j < 3);
177 Eigen::Vector3d axis = Eigen::Vector3d::Zero();
179 R = Eigen::AngleAxisd(r[j], axis).toRotationMatrix() * R;