46 if (
param ==
"temperature")
47 this->readBoundaryConditions(manager, source, temperature_boundary);
49 else if (
param ==
"heatflux")
50 this->readBoundaryConditions(manager, source, heatflux_boundary);
52 else if (
param ==
"convection")
53 this->readBoundaryConditions(manager, source, convection_boundary);
55 else if (
param ==
"radiation")
56 this->readBoundaryConditions(manager, source, radiation_boundary);
58 else if (
param ==
"loop") {
59 inittemp = source.
getAttribute<
double>(
"inittemp", inittemp);
64 else if (!this->parseFemConfiguration(source, manager)) {
65 this->parseStandardConfiguration(source, manager);
79 temperatures.reset(this->maskedMesh->size(), inittemp);
81 thickness.reset(this->maskedMesh->getElementsCount(),
NAN);
83 for (
auto elem: this->maskedMesh->elements())
85 if (!
isnan(thickness[
elem.getIndex()]))
continue;
86 auto material = this->geometry->getMaterial(
elem.getMidpoint());
87 double top =
elem.getUpper1(), bottom =
elem.getLower1();
90 size_t c =
elem.getIndex0();
91 for (
size_t r =
row; r > 0; r--) {
92 auto e = this->mesh->element(c, r-1);
93 auto m = this->geometry->getMaterial(
e.getMidpoint());
95 bottom =
e.getLower1();
99 for (
size_t r =
elem.getIndex1()+1; r < this->mesh->axis[1]->size()-1; r++) {
100 auto e = this->mesh->element(c, r);
101 auto m = this->geometry->getMaterial(
e.getMidpoint());
107 double h = top - bottom;
109 size_t idx = this->maskedMesh->element(c, r).getIndex();
445 this->initCalculation();
450 auto btemperature = temperature_boundary(this->maskedMesh, this->geometry);
451 auto bheatflux = heatflux_boundary(this->maskedMesh, this->geometry);
452 auto bconvection = convection_boundary(this->maskedMesh, this->geometry);
453 auto bradiation = radiation_boundary(this->maskedMesh, this->geometry);
458 size_t size = this->maskedMesh->size();
460 std::unique_ptr<FemMatrix>
pA(this->getMatrix());
467 if (!temperatures.unique()) this->
writelog(
LOG_DEBUG,
"Temperature data held by something else...");
469 temperatures = temperatures.claim();
474 std::copy(temperatures.begin(), temperatures.end(),
temp0.begin());
477 A.solve(B, temperatures);
482 for (
auto temp = temperatures.begin(), t =
temp0.begin(); t !=
temp0.end(); ++
temp, ++t)
488 if (err > toterr) toterr = err;
494 this->
writelog(
LOG_RESULT,
"Loop {:d}({:d}): max(T) = {:.3f} K, error = {:g} K", loop, loopno, maxT, err);
496 }
while ((!this->iter_params.converged || err > maxerr) && (
loops == 0 ||
loop <
loops));
498 outTemperature.fireChanged();
499 outHeatFlux.fireChanged();
509 fluxes.reset(this->maskedMesh->getElementsCount());
511 for (
auto e: this->maskedMesh->elements())
514 auto material = this->geometry->getMaterial(
midpoint);
529 std::tie(kx,ky) = std::tuple<double,double>(material->thermk(
temp,
leaf->getBoundingBox().height()));
531 std::tie(kx,ky) = std::tuple<double,double>(material->thermk(
temp));
534 fluxes[
e.getIndex()] =
vec(
538 + temperatures[
upleftno] + temperatures[
uprghtno]) / (
e.getUpper1() -
e.getLower1()));
582 auto point = flags.wrap(dest_mesh->at(i));
583 std::size_t x = solver->mesh->axis[0]->findUpIndex(point[0]),
584 y = solver->mesh->axis[1]->findUpIndex(point[1]);
585 if (x == 0 || y == 0 || x == solver->mesh->axis[0]->size() || y == solver->mesh->axis[1]->size())
588 auto elem = solver->maskedMesh->element(x-1, y-1);
589 size_t idx =
elem.getIndex();
591 auto material = solver->geometry->getMaterial(
elem.getMidpoint());
592 return material->thermk(temps[idx], solver->thickness[idx]);