15 bool matches_fe_space(
const int entry_fe_space_id,
const int fe_space_id)
17 return entry_fe_space_id < 0 || fe_space_id < 0 || entry_fe_space_id == fe_space_id;
20 int fe_space_id(
const json &entry)
22 return entry.value(
"fe_space", -1);
25 bool is_body_value_entry(
const json &entry)
27 if (!entry.is_object() || !entry.contains(
"id") || !entry.contains(
"value"))
30 const json &
id = entry[
"id"];
33 for (
const json &value : id)
34 if (value.is_number_integer() && value.get<int>() != -1)
39 return id.is_number_integer() &&
id.get<
int>() != -1;
42 bool has_body_value_entries(
const json &value)
44 return is_body_value_entry(value) || (value.is_array() && !value.empty() && is_body_value_entry(value.front()));
47 template <
typename Map>
48 const typename Map::mapped_type *find_for_fe_space(
const Map &values,
const int fe_space_id)
50 if (
const auto it = values.find(fe_space_id); it != values.end())
52 if (
const auto it = values.find(-1); it != values.end())
54 if (fe_space_id < 0 && values.size() == 1)
55 return &values.begin()->second;
59 std::vector<json> flatten_ids(
const json &p_j_boundary_tmp)
63 std::vector<json> j_boundary;
65 for (
size_t i = 0; i < j_boundary_tmp.size(); ++i)
67 const auto &
tmp = j_boundary_tmp[i];
71 j_boundary.push_back(tmp);
74 if (!
tmp.contains(
"id"))
77 if (tmp[
"id"].is_array())
79 for (
size_t j = 0; j <
tmp[
"id"].size(); ++j)
82 newj[
"id"] =
tmp[
"id"][j].get<
int>();
83 j_boundary.push_back(newj);
87 j_boundary.push_back(tmp);
98 double z = pts.size() == 2 ? 0 : pts(2);
118 assert(pts.size() == 2 || pts.size() == 3);
119 double x = pts(0),
y = pts(1),
z = pts.size() == 3 ? pts(2) : 0.0;
124 :
Problem(name), is_all_(false)
132 for (
int i = 0; i < 3; ++i)
134 for (
auto &[fe_space_id,
rhs] :
rhs_)
135 rhs[i].set_unit_type(units.
force());
138 for (
int i = 0; i < 3; ++i)
145 v.set_unit_type(units.
force());
154 v.second.set_unit_type(units.
pressure());
157 for (
int i = 0; i < 3; ++i)
158 v.value[i].set_unit_type(units.
velocity());
161 for (
int i = 0; i < 3; ++i)
162 v.value[i].set_unit_type(units.
velocity());
165 for (
int i = 0; i < 3; ++i)
169 v.second.set_unit_type(units.
velocity());
172 v.second.set_unit_type(units.
force());
176 for (
int i = 0; i < 3; ++i)
178 for (
auto &[fe_space_id,
rhs] :
rhs_)
182 for (
int i = 0; i < 3; ++i)
186 v.set_unit_type(units.
length());
189 v.set_unit_type(units.
force());
198 v.second.set_unit_type(units.
pressure());
201 for (
int i = 0; i < 3; ++i)
202 v.value[i].set_unit_type(units.
length());
205 for (
int i = 0; i < 3; ++i)
206 v.value[i].set_unit_type(units.
velocity());
209 for (
int i = 0; i < 3; ++i)
213 v.second.set_unit_type(units.
length());
216 v.second.set_unit_type(units.
force());
222 const auto *
rhs = find_for_fe_space(
rhs_, fe_space_id);
223 const auto *rhs_size = find_for_fe_space(
rhs_size_, fe_space_id);
224 const int size = rhs_size ==
nullptr ? pts.cols() : *rhs_size;
225 val.resize(pts.rows(), size);
233 const bool planar = pts.cols() == 2;
234 for (
int i = 0; i < pts.rows(); ++i)
236 for (
int j = 0; j < size; ++j)
238 double x = pts(i, 0),
y = pts(i, 1),
z = planar ? 0 : pts(i, 2);
239 val(i, j) = (*rhs)[j](
x,
y,
z, t);
248 rhs(assembler, pts, t,
val, fe_space_id);
252 int value_size = pts.cols();
255 if (matches_fe_space(entry.fe_space_id, fe_space_id))
257 value_size = entry.size;
262 val.resize(pts.rows(), value_size);
269 if (entry.body_id == body_id && matches_fe_space(entry.fe_space_id, fe_space_id))
276 if (body_rhs ==
nullptr)
279 const bool planar = pts.cols() == 2;
280 for (
int i = 0; i < pts.rows(); ++i)
282 for (
int j = 0; j <
val.cols(); ++j)
284 const double x = pts(i, 0),
y = pts(i, 1),
z = planar ? 0 : pts(i, 2);
292 const auto *
rhs = find_for_fe_space(
rhs_, fe_space_id);
293 const auto *rhs_size = find_for_fe_space(
rhs_size_, fe_space_id);
294 if (
rhs !=
nullptr && rhs_size !=
nullptr)
296 for (
int i = 0; i < *rhs_size; ++i)
297 if (!(*
rhs)[i].is_zero())
303 if (!matches_fe_space(entry.fe_space_id, fe_space_id))
305 for (
int i = 0; i < entry.size; ++i)
306 if (!entry.value[i].is_zero())
357 if (!matches_fe_space(displacement.fe_space_id, fe_space_id))
360 for (
int d = 0; d < displacement.dirichlet_dimension.size(); ++d)
362 if (!displacement.dirichlet_dimension(d))
369 for (
int i = 0; i < n_dirichlet.rows(); ++i)
371 for (
int d = 1; d < n_dirichlet.cols(); ++d)
373 if (std::isnan(n_dirichlet(i, d)))
387 if (displacement.size > 0 && matches_fe_space(displacement.fe_space_id, fe_space_id))
389 value_size = displacement.size;
393 val = Eigen::MatrixXd::Zero(pts.rows(), value_size);
395 for (
long i = 0; i < pts.rows(); ++i)
412 void GenericTensorProblem::neumann_bc(
const mesh::Mesh &mesh,
const Eigen::MatrixXi &global_ids,
const Eigen::MatrixXd &uv,
const Eigen::MatrixXd &pts,
const Eigen::MatrixXd &normals,
const double t, Eigen::MatrixXd &
val,
const int fe_space_id)
const
414 val = Eigen::MatrixXd::Zero(pts.rows(), mesh.
dimension());
416 for (
long i = 0; i < pts.rows(); ++i)
424 for (
int d = 0; d < std::min<int>(
val.cols(),
forces_[b].size); ++d)
426 val(i, d) =
forces_[b].eval(pts.row(i), d, t);
437 for (
int d = 0; d <
val.cols(); ++d)
449 val = Eigen::MatrixXd::Zero(pts.rows(), 1);
451 for (
long i = 0; i < pts.rows(); ++i)
476 const bool planar = pts.cols() == 2;
477 val.resize(pts.rows(), pts.cols());
479 for (
int i = 0; i < pts.rows(); ++i)
481 for (
int j = 0; j < pts.cols(); ++j)
483 double x = pts(i, 0),
y = pts(i, 1),
z = planar ? 0 : pts(i, 2);
491 const int size = pts.cols();
492 val.resize(pts.rows(), pts.cols() * size);
496 const bool planar = size == 2;
497 for (
int i = 0; i < pts.rows(); ++i)
499 for (
int j = 0; j < pts.cols() * size; ++j)
501 double x = pts(i, 0),
y = pts(i, 1),
z = planar ? 0 : pts(i, 2);
517 for (
int d = 0; d <
val.cols(); ++d)
525 for (
int i = 0; i < n_dirichlet.rows(); ++i)
527 if (n_dirichlet(i, 0) == node_id)
529 for (
int d = 0; d <
val.cols(); ++d)
531 val(d) = n_dirichlet(i, d + 1);
549 val = Eigen::MatrixXd::Zero(1, it->second.size);
550 for (
int d = 0; d <
val.cols(); ++d)
551 val(d) = it->second.eval(pt, d, t);
557 for (
int i = 0; i < n_neumann.rows(); ++i)
559 if (n_neumann(i, 0) == node_id)
561 val.resize(1, n_neumann.cols() - 1);
562 for (
int d = 0; d <
val.cols(); ++d)
563 val(d) = n_neumann(i, d + 1);
580 for (
int i = 0; i < n_dirichlet.rows(); ++i)
582 if (n_dirichlet(i, 0) == n_id)
593 return matches_fe_space(it->second.fe_space_id, fe_space_id);
597 for (
int i = 0; i < n_neumann.rows(); ++i)
599 if (n_neumann(i, 0) == n_id)
620 if (matches_fe_space(force.fe_space_id, fe_space_id))
634 for (
int i = 0; i < n_dirichlet.rows(); ++i)
636 if (n_dirichlet(i, 0) == n_id)
638 return !std::isnan(n_dirichlet(i, dim + 1));
652 logger().debug(
"Skipping updating in nodes to nodes in problem, already done once...");
657 for (
int n = 0; n < n_dirichlet.rows(); ++n)
659 const int node_id = in_node_to_node[n_dirichlet(n, 0)];
660 n_dirichlet(n, 0) = node_id;
665 for (
int n = 0; n < n_neumann.rows(); ++n)
667 const int node_id = in_node_to_node[n_neumann(n, 0)];
668 n_neumann(n, 0) = node_id;
683 const json &rr = params[
"rhs"];
684 const bool has_fe_spaces = rr.is_array() && !rr.empty() && rr.front().is_object() && rr.front().contains(
"fe_space") && rr.front().contains(
"value");
685 const bool has_body_ids = has_body_value_entries(rr);
688 const std::vector<json>
entries = flatten_ids(rr);
690 for (
size_t k = 0; k <
entries.size(); ++k)
694 const auto &value =
entries[k][
"value"];
695 body_rhs_[k].size = value.is_array() ? int(value.size()) : 1;
698 for (
int d = 0; d <
body_rhs_[k].size; ++d)
699 body_rhs_[k].value[d].
init(value.is_array() ? value[d] : value, resources);
702 else if (has_fe_spaces)
704 for (
const json &entry : rr)
706 const int id = fe_space_id(entry);
707 const json &value = entry[
"value"];
708 const int size = value.is_array() ? int(value.size()) : 1;
710 log_and_throw_error(
"RHS for FE space {} has {} components; at most 3 are supported.",
id, size);
712 for (
int k = 0; k < size; ++k)
713 rhs_[
id][k].
init(value.is_array() ? value[k] : value, resources);
716 else if (rr.is_array() && !rr.empty())
721 for (
size_t k = 0; k < rr.size(); ++k)
724 else if (!rr.is_array())
730 auto ex = params[
"reference"][
"solution"];
734 for (
size_t k = 0; k < ex.size(); ++k)
745 auto ex = params[
"reference"][
"gradient"];
749 for (
size_t k = 0; k < ex.size(); ++k)
762 std::vector<json> j_boundary = flatten_ids(params[
"dirichlet_boundary"]);
769 if (j_boundary[i - offset].is_string())
771 const std::string path = j_boundary[i - offset].get<std::string>();
778 displacements_[i].fe_space_id = fe_space_id(j_boundary[i - offset]);
780 if (j_boundary[i - offset][
"id"] ==
"all")
794 auto ff = j_boundary[i - offset][
"value"];
800 for (
size_t k = 0; k < ff.size(); ++k)
803 if (j_boundary[i - offset].contains(
"time_reference") && j_boundary[i - offset][
"time_reference"].size() > 0)
804 displacements_[i].value[k].set_t(j_boundary[i - offset][
"time_reference"]);
818 if (j_boundary[i - offset].contains(
"dimension"))
820 auto &tmp = j_boundary[i - offset][
"dimension"];
821 assert(tmp.is_array());
822 for (
size_t k = 0; k < tmp.size(); ++k)
829 if (j_boundary[i - offset][
"interpolation"].is_array())
831 for (
int ii = 0; ii < j_boundary[i - offset][
"interpolation"].size(); ++ii)
846 auto j_boundary_tmp = params[
"neumann_boundary"];
847 std::vector<json> j_boundary = flatten_ids(j_boundary_tmp);
850 forces_.resize(offset + j_boundary.size());
855 forces_[i].fe_space_id = fe_space_id(j_boundary[i - offset]);
857 auto ff = j_boundary[i - offset][
"value"];
858 forces_[i].size = ff.is_array() ? int(ff.size()) : 1;
861 for (
int k = 0; k <
forces_[i].size; ++k)
862 forces_[i].value[k].
init(ff.is_array() ? ff[k] : ff, resources);
864 if (j_boundary[i - offset][
"interpolation"].is_array())
866 for (
int ii = 0; ii < j_boundary[i - offset][
"interpolation"].size(); ++ii)
878 std::vector<json> j_boundary = flatten_ids(params[
"nodal_neumann_boundary"]);
880 for (
size_t i = 0; i < j_boundary.size(); ++i)
882 if (j_boundary[i].is_string())
884 const std::string path = j_boundary[i].get<std::string>();
890 const int id = j_boundary[i][
"id"];
892 nodal_neumann.
fe_space_id = fe_space_id(j_boundary[i]);
894 auto ff = j_boundary[i][
"value"];
895 nodal_neumann.
size = ff.is_array() ? int(ff.size()) : 1;
896 if (nodal_neumann.
size > 3)
898 for (
int k = 0; k < nodal_neumann.
size; ++k)
899 nodal_neumann.
value[k].init(ff.is_array() ? ff[k] : ff, resources);
901 if (j_boundary[i][
"interpolation"].is_array())
903 for (
int ii = 0; ii < j_boundary[i][
"interpolation"].size(); ++ii)
919 auto j_boundary_tmp = params[
"normal_aligned_neumann_boundary"];
920 std::vector<json> j_boundary = flatten_ids(j_boundary_tmp);
930 auto ff = j_boundary[i - offset][
"value"];
933 if (j_boundary[i - offset].contains(
"interpolation"))
945 auto j_boundary_tmp = params[
"pressure_boundary"];
946 std::vector<json> j_boundary = flatten_ids(j_boundary_tmp);
949 pressures_.resize(offset + j_boundary.size());
955 auto ff = j_boundary[i - offset][
"value"];
957 if (j_boundary[i - offset].contains(
"time_reference") && j_boundary[i - offset][
"time_reference"].size() > 0)
958 pressures_[i].value.set_t(j_boundary[i - offset][
"time_reference"]);
960 pressures_[i].interpolation = std::make_shared<NoInterpolation>();
968 auto j_boundary_tmp = params[
"pressure_cavity"];
969 std::vector<json> j_boundary = flatten_ids(j_boundary_tmp);
975 int boundary_id = j_boundary[i - offset][
"id"];
982 auto ff = j_boundary[i - offset][
"value"];
985 cavity_pressures_[boundary_id].interpolation = std::make_shared<NoInterpolation>();
992 auto rr = params[
"solution"];
994 assert(rr.is_array());
996 for (
size_t k = 0; k < rr.size(); ++k)
1000 const auto v = rr[k][
"value"];
1011 auto rr = params[
"velocity"];
1013 assert(rr.is_array());
1015 for (
size_t k = 0; k < rr.size(); ++k)
1019 const auto v = rr[k][
"value"];
1030 auto rr = params[
"acceleration"];
1032 assert(rr.is_array());
1034 for (
size_t k = 0; k < rr.size(); ++k)
1038 const auto v = rr[k][
"value"];
1050 int value_size = pts.cols();
1052 if (matches_fe_space(entry.fe_space_id, fe_space_id))
1054 value_size = entry.size;
1057 val.resize(pts.rows(), value_size);
1064 const bool planar = pts.cols() == 2;
1065 for (
int i = 0; i < pts.rows(); ++i)
1079 val.row(i).setZero();
1083 for (
int j = 0; j <
val.cols(); ++j)
1090 int value_size = pts.cols();
1092 if (matches_fe_space(entry.fe_space_id, fe_space_id))
1094 value_size = entry.size;
1097 val.resize(pts.rows(), value_size);
1104 const bool planar = pts.cols() == 2;
1105 for (
int i = 0; i < pts.rows(); ++i)
1119 val.row(i).setZero();
1123 for (
int j = 0; j <
val.cols(); ++j)
1130 int value_size = pts.cols();
1132 if (matches_fe_space(entry.fe_space_id, fe_space_id))
1134 value_size = entry.size;
1137 val.resize(pts.rows(), value_size);
1144 const bool planar = pts.cols() == 2;
1145 for (
int i = 0; i < pts.rows(); ++i)
1159 val.row(i).setZero();
1163 for (
int j = 0; j <
val.cols(); ++j)
1192 for (
int i = 0; i <
exact_.size(); ++i)
1201 :
Problem(name), is_all_(false)
1210 v.set_unit_type(
"");
1213 v.set_unit_type(
"");
1216 v.second.set_unit_type(
"");
1219 v.second.set_unit_type(
"");
1222 v.value.set_unit_type(
"");
1224 for (
auto &[fe_space_id,
rhs] :
rhs_)
1225 rhs.set_unit_type(
"");
1228 for (
int i = 0; i < 3; ++i)
1234 val.resize(pts.rows(), 1);
1235 const auto *
rhs = find_for_fe_space(
rhs_, fe_space_id);
1236 if (
rhs ==
nullptr ||
rhs->is_zero())
1241 const bool planar = pts.cols() == 2;
1242 for (
int i = 0; i < pts.rows(); ++i)
1244 double x = pts(i, 0),
y = pts(i, 1),
z = planar ? 0 : pts(i, 2);
1245 val(i) = (*rhs)(
x,
y,
z, t);
1253 rhs(assembler, pts, t,
val, fe_space_id);
1257 val.resize(pts.rows(), 1);
1264 if (entry.body_id == body_id && matches_fe_space(entry.fe_space_id, fe_space_id))
1271 if (body_rhs ==
nullptr)
1274 const bool planar = pts.cols() == 2;
1275 for (
int i = 0; i < pts.rows(); ++i)
1277 const double x = pts(i, 0),
y = pts(i, 1),
z = planar ? 0 : pts(i, 2);
1284 const auto *
rhs = find_for_fe_space(
rhs_, fe_space_id);
1285 if (
rhs !=
nullptr && !
rhs->is_zero())
1289 if (matches_fe_space(entry.fe_space_id, fe_space_id) && !entry.value.is_zero())
1314 val = Eigen::MatrixXd::Zero(pts.rows(), 1);
1316 for (
long i = 0; i < pts.rows(); ++i)
1330 void GenericScalarProblem::neumann_bc(
const mesh::Mesh &mesh,
const Eigen::MatrixXi &global_ids,
const Eigen::MatrixXd &uv,
const Eigen::MatrixXd &pts,
const Eigen::MatrixXd &normals,
const double t, Eigen::MatrixXd &
val,
const int fe_space_id)
const
1332 val = Eigen::MatrixXd::Zero(pts.rows(), 1);
1334 for (
long i = 0; i < pts.rows(); ++i)
1342 double x = pts(i, 0),
y = pts(i, 1),
z = pts.cols() == 2 ? 0 : pts(i, 2);
1352 val.resize(pts.rows(), 1);
1359 const bool planar = pts.cols() == 2;
1360 for (
int i = 0; i < pts.rows(); ++i)
1385 const bool planar = pts.cols() == 2;
1386 val.resize(pts.rows(), 1);
1388 for (
int i = 0; i < pts.rows(); ++i)
1390 double x = pts(i, 0),
y = pts(i, 1),
z = pts.cols() == 2 ? 0 : pts(i, 2);
1397 val.resize(pts.rows(), pts.cols());
1401 const bool planar = pts.cols() == 2;
1402 for (
int i = 0; i < pts.rows(); ++i)
1404 for (
int j = 0; j < pts.cols(); ++j)
1406 double x = pts(i, 0),
y = pts(i, 1),
z = pts.cols() == 2 ? 0 : pts(i, 2);
1425 throw "Invalid boundary id for pressure update";
1430 Eigen::MatrixXd curr_val =
pressures_[index].value.get_mat();
1431 assert(time_step <= curr_val.size());
1432 assert(curr_val.cols() == 1);
1433 curr_val(time_step) =
val;
1455 throw "Invalid boundary id for dirichlet update";
1458 for (
int i = 0; i <
val.size(); ++i)
1462 Eigen::MatrixXd curr_val =
displacements_[index].value[i].get_mat();
1463 assert(time_step <= curr_val.size());
1464 assert(curr_val.cols() == 1);
1465 curr_val(time_step) =
val(i);
1477 assert(node_ids.size() == nodal_dirichlet.rows());
1481 for (
int i = 0; i < node_ids.size(); ++i)
1483 int mapped_node_id = in_node_to_node(node_ids(i));
1484 for (
int j = 0; j < n_dirichlet.rows(); ++j)
1485 if (mapped_node_id == n_dirichlet(j, 0))
1486 for (
int k = 0; k < n_dirichlet.cols() - 1; ++k)
1487 n_dirichlet(j, k + 1) = nodal_dirichlet(i, k);
1493 val = Eigen::MatrixXd::Zero(1, 1);
1507 for (
int i = 0; i < n_dirichlet.rows(); ++i)
1509 if (n_dirichlet(i, 0) == node_id)
1511 val(0) = n_dirichlet(i, 1);
1522 val = Eigen::MatrixXd::Zero(1, 1);
1527 val(0) = it->second.eval(pt, t);
1533 for (
int i = 0; i < n_neumann.rows(); ++i)
1535 if (n_neumann(i, 0) == node_id)
1537 val(0) = n_neumann(i, 1);
1554 for (
int i = 0; i < n_dirichlet.rows(); ++i)
1556 if (n_dirichlet(i, 0) == n_id)
1567 return matches_fe_space(it->second.fe_space_id, fe_space_id);
1571 for (
int i = 0; i < n_neumann.rows(); ++i)
1573 if (n_neumann(i, 0) == n_id)
1594 if (matches_fe_space(neumann.fe_space_id, fe_space_id))
1606 for (
int n = 0; n < n_dirichlet.rows(); ++n)
1608 const int node_id = in_node_to_node[n_dirichlet(n, 0)];
1609 n_dirichlet(n, 0) = node_id;
1614 for (
int n = 0; n < n_neumann.rows(); ++n)
1616 const int node_id = in_node_to_node[n_neumann(n, 0)];
1617 n_neumann(n, 0) = node_id;
1632 const json &rr = params[
"rhs"];
1633 const bool has_fe_spaces = rr.is_array() && !rr.empty() && rr.front().is_object() && rr.front().contains(
"fe_space") && rr.front().contains(
"value");
1634 const bool has_body_ids = has_body_value_entries(rr);
1637 const std::vector<json>
entries = flatten_ids(rr);
1639 for (
size_t k = 0; k <
entries.size(); ++k)
1646 else if (has_fe_spaces)
1648 for (
const json &entry : rr)
1649 rhs_[fe_space_id(entry)].init(entry[
"value"], resources);
1651 else if (!rr.is_array() || !rr.empty())
1657 has_exact_ = !params[
"reference"][
"solution"].empty();
1658 exact_.
init(params[
"reference"][
"solution"], resources);
1663 auto ex = params[
"reference"][
"gradient"];
1667 for (
size_t k = 0; k < ex.size(); ++k)
1680 std::vector<json> j_boundary = flatten_ids(params[
"dirichlet_boundary"]);
1683 dirichlet_.resize(offset + j_boundary.size());
1687 if (j_boundary[i - offset].is_string())
1689 const std::string path = j_boundary[i - offset].get<std::string>();
1695 int current_id = -1;
1696 dirichlet_[i].fe_space_id = fe_space_id(j_boundary[i - offset]);
1698 if (j_boundary[i - offset][
"id"] ==
"all")
1712 auto ff = j_boundary[i - offset][
"value"];
1716 if (j_boundary[i - offset][
"interpolation"].is_array())
1718 if (j_boundary[i - offset][
"interpolation"].size() == 0)
1719 dirichlet_[i].interpolation = std::make_shared<NoInterpolation>();
1720 else if (j_boundary[i - offset][
"interpolation"].size() == 1)
1736 auto j_boundary_tmp = params[
"neumann_boundary"];
1737 std::vector<json> j_boundary = flatten_ids(j_boundary_tmp);
1740 neumann_.resize(offset + j_boundary.size());
1745 neumann_[i].fe_space_id = fe_space_id(j_boundary[i - offset]);
1747 auto ff = j_boundary[i - offset][
"value"];
1748 neumann_[i].value.init(ff, resources);
1750 if (j_boundary[i - offset][
"interpolation"].is_array())
1752 if (j_boundary[i - offset][
"interpolation"].size() == 0)
1753 neumann_[i].interpolation = std::make_shared<NoInterpolation>();
1754 else if (j_boundary[i - offset][
"interpolation"].size() == 1)
1766 std::vector<json> j_boundary = flatten_ids(params[
"nodal_neumann_boundary"]);
1768 for (
size_t i = 0; i < j_boundary.size(); ++i)
1770 if (j_boundary[i].is_string())
1772 const std::string path = j_boundary[i].get<std::string>();
1778 const int id = j_boundary[i][
"id"];
1780 nodal_neumann.
fe_space_id = fe_space_id(j_boundary[i]);
1781 nodal_neumann.
value.
init(j_boundary[i][
"value"], resources);
1783 if (j_boundary[i][
"interpolation"].is_array())
1785 if (j_boundary[i][
"interpolation"].size() == 0)
1786 nodal_neumann.
interpolation = std::make_shared<NoInterpolation>();
1787 else if (j_boundary[i][
"interpolation"].size() == 1)
1801 auto rr = params[
"solution"];
1803 assert(rr.is_array());
1805 for (
size_t k = 0; k < rr.size(); ++k)
std::vector< Eigen::Triplet< double > > entries
std::string force() const
std::string pressure() const
std::string velocity() const
std::string acceleration() const
const std::string & length() const
virtual bool is_fluid() const
void neumann_bc(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &uv, const Eigen::MatrixXd &pts, const Eigen::MatrixXd &normals, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
bool is_nodal_neumann_boundary(const int n_id, const int tag, const int fe_space_id=-1) override
std::vector< ScalarBCValue > neumann_
void initial_solution(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &pts, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::vector< Eigen::MatrixXd > nodal_neumann_mat_
void update_nodes(const Eigen::VectorXi &in_node_to_node) override
void dirichlet_nodal_value(const mesh::Mesh &mesh, const int node_id, const RowVectorNd &pt, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
bool is_nodal_dirichlet_boundary(const int n_id, const int tag, const int fe_space_id=-1) override
std::vector< ScalarInitialValue > body_rhs_
utils::ExpressionValue exact_
std::array< utils::ExpressionValue, 3 > exact_grad_
bool has_nodal_dirichlet(const int fe_space_id=-1) override
void exact_grad(const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val) const override
bool has_nodal_neumann(const int fe_space_id=-1) override
std::map< int, utils::ExpressionValue > rhs_
void set_parameters(const json ¶ms, const io::ResourceIO &resources) override
void neumann_nodal_value(const mesh::Mesh &mesh, const int node_id, const RowVectorNd &pt, const Eigen::MatrixXd &normal, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::map< int, ScalarBCValue > nodal_dirichlet_
void rhs(const assembler::Assembler &assembler, const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::vector< ScalarInitialValue > initial_solution_
bool is_rhs_zero(const int fe_space_id=-1) const override
void set_units(const assembler::Assembler &assembler, const Units &units) override
GenericScalarProblem(const std::string &name)
std::map< int, ScalarBCValue > nodal_neumann_
bool has_exact_sol() const override
std::vector< ScalarBCValue > dirichlet_
bool has_boundary(const BoundaryKind kind, const int tag, const int fe_space_id) override
void exact(const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val) const override
void dirichlet_bc(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &uv, const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::vector< Eigen::MatrixXd > nodal_dirichlet_mat_
void update_pressure_boundary(const int id, const int time_step, const double val)
bool has_boundary(const BoundaryKind kind, const int tag, const int fe_space_id) override
std::map< int, TensorBCValue > nodal_neumann_
std::vector< TensorInitialValue > initial_acceleration_
void initial_acceleration(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &pts, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
void initial_solution(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &pts, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::unordered_map< int, ScalarBCValue > cavity_pressures_
std::vector< TensorInitialValue > initial_position_
void rhs(const assembler::Assembler &assembler, const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
void update_nodes(const Eigen::VectorXi &in_node_to_node) override
GenericTensorProblem(const std::string &name)
std::map< int, int > rhs_size_
std::vector< TensorInitialValue > body_rhs_
std::vector< TensorInitialValue > initial_velocity_
bool all_dimensions_dirichlet(const int fe_space_id) const override
void update_dirichlet_nodes(const Eigen::VectorXi &in_node_to_node, const Eigen::VectorXi &node_ids, const Eigen::MatrixXd &nodal_dirichlet)
std::vector< TensorBCValue > displacements_
void neumann_bc(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &uv, const Eigen::MatrixXd &pts, const Eigen::MatrixXd &normals, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::vector< ScalarBCValue > normal_aligned_forces_
std::map< int, std::array< utils::ExpressionValue, 3 > > rhs_
bool is_nodal_dimension_dirichlet(const int n_id, const int tag, const int dim, const int fe_space_id=-1) const override
void dirichlet_bc(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &uv, const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::vector< Eigen::MatrixXd > nodal_neumann_mat_
bool is_nodal_neumann_boundary(const int n_id, const int tag, const int fe_space_id=-1) override
bool is_dimension_dirichet(const int tag, const int dim, const int fe_space_id=-1) const override
void pressure_bc(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &uv, const Eigen::MatrixXd &pts, const Eigen::MatrixXd &normals, const double t, Eigen::MatrixXd &val) const override
void exact(const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val) const override
std::map< int, TensorBCValue > nodal_dirichlet_
bool has_nodal_neumann(const int fe_space_id=-1) override
std::array< utils::ExpressionValue, 9 > exact_grad_
void set_parameters(const json ¶ms, const io::ResourceIO &resources) override
bool is_rhs_zero(const int fe_space_id=-1) const override
void dirichlet_nodal_value(const mesh::Mesh &mesh, const int node_id, const RowVectorNd &pt, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::vector< TensorBCValue > forces_
void update_dirichlet_boundary(const int id, const int time_step, const Eigen::VectorXd &val)
double pressure_cavity_bc(const int boundary_id, const double t) const override
std::vector< ScalarBCValue > pressures_
bool is_nodal_dirichlet_boundary(const int n_id, const int tag, const int fe_space_id=-1) override
void neumann_nodal_value(const mesh::Mesh &mesh, const int node_id, const RowVectorNd &pt, const Eigen::MatrixXd &normal, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
bool has_exact_sol() const override
void exact_grad(const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val) const override
bool has_nodal_dirichlet(const int fe_space_id=-1) override
void set_units(const assembler::Assembler &assembler, const Units &units) override
std::array< utils::ExpressionValue, 3 > exact_
std::vector< Eigen::MatrixXd > nodal_dirichlet_mat_
void initial_velocity(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &pts, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
std::vector< int > normal_aligned_neumann_boundary_ids_
bool updated_dirichlet_node_ordering_
std::vector< int > pressure_boundary_ids_
std::vector< int > boundary_ids_
virtual void init(const mesh::Mesh &mesh)
std::vector< int > neumann_boundary_ids_
std::vector< int > pressure_cavity_ids_
Read-only interface to a hierarchical collection of simulation resources.
virtual Eigen::MatrixXd read_matrix(const std::string &path) const =0
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
virtual int get_body_id(const int primitive) const
Get the volume selection of an element (cell in 3d, face in 2d)
virtual int get_boundary_id(const int primitive) const
Get the boundary selection of an element (face in 3d, edge in 2d)
int dimension() const
utily for dimension
virtual int get_node_id(const int node_id) const
Get the boundary selection of a node.
void set_unit_type(const std::string &unit_type)
void init(const json &vals, const io::ResourceIO &resources)
static std::shared_ptr< Interpolation > build(const json ¶ms)
std::vector< T > json_as_array(const json &j)
Return the value of a json object as an array.
bool is_param_valid(const json ¶ms, const std::string &key)
Determine if a key exists and is non-null in a json object.
spdlog::logger & logger()
Retrieves the current logger.
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
void log_and_throw_error(const std::string &msg)
std::shared_ptr< utils::Interpolation > interpolation
double eval(const RowVectorNd &pts, const double t) const
utils::ExpressionValue value
utils::ExpressionValue value
std::vector< std::shared_ptr< utils::Interpolation > > interpolation
std::array< utils::ExpressionValue, 3 > value
double eval(const RowVectorNd &pts, const int dim, const double t, const int el_id=-1) const
std::array< utils::ExpressionValue, 3 > value