50 if (!this->geometry || !this->mesh)
return;
52 this->setupMaskedMesh();
54 auto points = this->mesh->getElementMesh();
56 std::vector<typename Active::Region> regions;
58 for (
size_t r = 0; r < points->axis[1]->size(); ++r) {
61 for (
size_t c = 0; c < points->axis[0]->size(); ++c) {
62 auto point = points->at(c, r);
63 size_t num = isActive(point);
66 if (regions.size() >= num && regions[num - 1].warn) {
68 material = this->geometry->getMaterial(points->at(c, r));
69 else if (*material != *this->geometry->getMaterial(points->at(c, r))) {
71 regions[num - 1].warn =
false;
74 regions.resize(
max(regions.size(), num));
75 auto& reg = regions[num - 1];
78 throw Exception(
"{0}: Junction {1} is disjoint", this->getId(), num - 1);
82 else if (reg.rowr <= c)
83 throw Exception(
"{0}: Junction {1} is disjoint", this->getId(), num - 1);
86 if (reg.left > reg.rowl) reg.left = reg.rowl;
89 if (prev && prev != num) {
90 auto& reg = regions[prev - 1];
91 if (reg.bottom < r && reg.rowl >= c)
throw Exception(
"{0}: Junction {1} is disjoint", this->getId(), prev - 1);
93 if (reg.right < reg.rowr) reg.right = reg.rowr;
98 regions[prev - 1].rowr = regions[prev - 1].right = points->axis[0]->size();
103 active.reserve(regions.size());
105 for (
auto& reg : regions) {
106 if (reg.bottom == std::numeric_limits<size_t>::max()) reg.bottom = reg.top = 0;
107 active.emplace_back(
condsize, reg.left, reg.right, reg.bottom, reg.top,
108 this->mesh->axis[1]->at(reg.top) -
this->mesh->axis[1]->at(reg.bottom));
110 this->
writelog(
LOG_DETAIL,
"Detected junction {0} thickness = {1}nm", i++, 1
e3 * active.back().height);
111 this->
writelog(
LOG_DEBUG,
"Junction {0} span: [{1},{3}]-[{2},{4}]", i - 1, reg.left, reg.right, reg.bottom, reg.top);
244 auto midmesh = this->maskedMesh->getElementMesh();
245 auto temperature = inTemperature(midmesh);
246 auto conductivity = inDifferentialConductivity(midmesh);
248 conductivities.reset(midmesh->size());
250 for (
auto e : this->maskedMesh->elements()) {
251 size_t i =
e.getIndex();
260 this->initCalculation();
263 auto vconst = voltage_boundary(this->maskedMesh, this->geometry);
267 std::unique_ptr<FemMatrix<dcomplex>>
pA(this->getMatrix());
271 if (!potentials.unique()) this->
writelog(
LOG_DEBUG,
"Voltage data held by something else...");
273 potentials = potentials.claim();
274 loadConductivities();
279 A.solve(
rhs, potentials);
283 outAcVoltage.fireChanged();
284 outAcCurrentDensity.fireChanged();