11 #include "libmesh/quadrature.h" 20 std::numeric_limits<Real>::max(),
21 "Tolerance for checking view factors. Default is to allow everything.");
23 "print_view_factor_info",
false,
"Flag to print information about computed view factors.");
24 params.
addParam<
bool>(
"normalize_view_factor",
26 "Determines if view factors are normalized to sum to one (consistent with " 27 "their definition).");
29 "A base class for automatic computation of view factors between sidesets.");
35 _n_sides(boundaryIDs().size()),
37 _view_factor_tol(getParam<
Real>(
"view_factor_tol")),
38 _normalize_view_factor(getParam<bool>(
"normalize_view_factor")),
39 _print_view_factor_info(getParam<bool>(
"print_view_factor_info"))
47 std::vector<BoundaryName> boundary_names = getParam<std::vector<BoundaryName>>(
"boundary");
48 for (
unsigned int j = 0;
j < boundary_names.size(); ++
j)
80 " not listed in boundary parameter.");
87 " not listed in boundary parameter.");
96 for (
unsigned int i = 0; i <
_n_sides; ++i)
107 for (
unsigned int i = 0; i <
_n_sides; ++i)
125 for (
unsigned int i = 0; i <
_n_sides; ++i)
139 for (
unsigned int to = 0; to <
_n_sides; ++to)
148 for (
unsigned int i = 0; i <
_n_sides; ++i)
163 Real max_correction = std::numeric_limits<Real>::lowest();
164 Real min_correction = std::numeric_limits<Real>::max();
167 _console <<
"\nSum of all view factors from side i to all other faces before normalization.\n" 172 for (
unsigned int from = 0; from <
_n_sides; ++from)
177 mooseError(
"Maximum deviation of view factor row sum is ",
179 " exceeding the set tolerance of ",
186 _console <<
"\nNormalizing view factors.\n" << std::endl;
194 for (
unsigned int i = 0; i <
_n_sides; ++i)
206 Real f = 2 * (1 + ar * ar);
207 matrix(i, i) += -1 /
f;
208 matrix(i,
j) += -1 /
f * ar;
213 for (
unsigned int j = 0;
j < i; ++
j)
216 Real f = 2 * (1 + ar * ar);
217 matrix(i, i) += -1 /
f * ar * ar;
218 matrix(i,
j) += -1 /
f * ar;
229 for (
unsigned int i = 0; i <
_n_sides; ++i)
234 correction = -0.5 * lmults(i);
238 Real f = 2 * (1 + ar * ar);
239 correction = -(lmults(i) + lmults(
j) * ar + 2 * ar * ar *
devReciprocity(i,
j)) /
f;
243 vf_temp[i][
j] += correction;
245 if (correction < min_correction)
246 min_correction = correction;
247 if (correction > max_correction)
248 max_correction = correction;
255 _console <<
"\nFinal view factors.\n" << std::endl;
256 for (
unsigned int from = 0; from <
_n_sides; ++from)
258 std::string from_name;
260 if (pair.second == from)
261 from_name = pair.first;
264 for (
unsigned int to = 0; to <
_n_sides; ++to)
268 if (pair.second == to)
269 to_name = pair.first;
271 _console << from_name <<
" (" << from_id <<
") -> " << to_name <<
" (" << to_id
283 _console << COLOR_CYAN <<
"Summary of the view factor computation" 285 << COLOR_DEFAULT << std::endl;
287 _console <<
"Normalization is performed." << std::endl;
289 _console <<
"Normalization is skipped." << std::endl;
290 _console << std::setw(60) << std::left <<
"Number of patches: " <<
_n_sides << std::endl;
291 _console << std::setw(60) << std::left
292 <<
"Max deviation sum = 1 before normalization: " << max_sum_deviation << std::endl;
293 _console << std::setw(60) << std::left
294 <<
"Max deviation from reciprocity before normalization: " << max_reciprocity_deviation
298 _console << std::setw(60) << std::left <<
"Maximum correction: " << max_correction << std::endl;
299 _console << std::setw(60) << std::left <<
"Minimum correction: " << min_correction << std::endl;
300 _console << std::setw(60) <<
"Max deviation sum = 1 after normalization: " 301 << max_sum_deviation_after_normalization << std::endl;
302 _console << std::setw(60) << std::left <<
"Max deviation from reciprocity after normalization: " 303 << max_reciprocity_deviation_after_normalization << std::endl;
311 mooseAssert(i <=
j,
"indexHelper requires i <= j");
315 for (
unsigned int l = 0; l <
_n_sides; ++l)
316 for (
unsigned int m = l + 1; m <
_n_sides; ++m)
318 if (l == i && m ==
j)
virtual void finalizeViewFactor()=0
a purely virtural function called in finalize, must be overriden by derived class ...
static InputParameters validParams()
unsigned int indexHelper(unsigned int i, unsigned int j) const
helper for finding index of correction for i,j-th entry
std::vector< Real > _areas
area of the sides i
virtual void finalize() override final
std::unordered_map< std::string, unsigned int > _side_name_index
boundary name to index map
const Real _view_factor_tol
view factor tolerance
ViewFactorBase(const InputParameters ¶meters)
unsigned int _n_sides
number of boundaries of this side uo
const std::string & getBoundaryName(BoundaryID boundary_id)
const bool _print_view_factor_info
const std::vector< double > y
const bool _normalize_view_factor
whether to normalize view factors so vf[from][:] sums to one
Real devReciprocity(unsigned int i, unsigned int j) const
this function computes the deviation from reciprocity defined as Fij - Aj/Ai * Fji ...
Real getViewFactor(BoundaryID from_id, BoundaryID to_id) const
public interface for obtaining view factors
virtual const std::string & name() const
A base class for automatic computation of view factors between sidesets.
Real maxDevRowSum() const
maximum deviation of any view factor row sum from 1
std::vector< std::vector< Real > > _view_factors
the view factor from side i to side j
Real f(Real x)
Test function for Brents method.
boundary_id_type BoundaryID
unsigned int getSideNameIndex(std::string name) const
helper function to get the index from the boundary name
Real viewFactorRowSum(unsigned int i) const
sum of a row in the view factor matrix
virtual void threadJoinViewFactor(const UserObject &y)=0
a purely virtual function called in finalize, must be overriden by derived class
static InputParameters validParams()
void checkAndNormalizeViewFactor()
this function checks & normalizes view factors to sum to one, this is not always
void lu_solve(const DenseVector< Real > &b, DenseVector< Real > &x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
virtual void threadJoin(const UserObject &y) override final
void mooseError(Args &&... args) const
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const ConsoleStream _console
const std::vector< BoundaryName > & boundaryNames() const
Real maxDevReciprocity() const
this function computes the maximum absolute value of the deviation from reciprocity ...
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const