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 MooseEnum normalization_method(
"lagrange_multiplier inverse_row_sum",
"lagrange_multiplier");
30 normalization_method.addDocumentation(
"lagrange_multiplier",
"Uses Lagrange multiplier method");
31 normalization_method.addDocumentation(
"inverse_row_sum",
32 "Divides each view factor by its row sum");
35 "Normalization method to use if 'normalize_view_factor' is 'true'.");
38 "A base class for automatic computation of view factors between sidesets.");
44 _n_sides(boundaryIDs().size()),
46 _view_factor_tol(getParam<
Real>(
"view_factor_tol")),
47 _normalize_view_factor(getParam<bool>(
"normalize_view_factor")),
48 _normalization_method(
50 _print_view_factor_info(getParam<bool>(
"print_view_factor_info"))
58 std::vector<BoundaryName> boundary_names = getParam<std::vector<BoundaryName>>(
"boundary");
59 for (
unsigned int j = 0;
j < boundary_names.size(); ++
j)
91 " not listed in boundary parameter.");
98 " not listed in boundary parameter.");
117 current_boundary_name,
120 " not in boundary parameter.");
138 for (
unsigned int i = 0; i <
_n_sides; ++i)
139 _areas[i] += pps._areas[i];
154 for (
unsigned int i = 0; i <
_n_sides; ++i)
168 for (
unsigned int to = 0; to <
_n_sides; ++to)
177 for (
unsigned int i = 0; i <
_n_sides; ++i)
192 Real max_correction = std::numeric_limits<Real>::lowest();
193 Real min_correction = std::numeric_limits<Real>::max();
196 _console <<
"\nSum of all view factors from side i to all other faces before normalization.\n" 201 for (
unsigned int from = 0; from <
_n_sides; ++from)
206 mooseError(
"Maximum deviation of view factor row sum is ",
208 " exceeding the set tolerance of ",
215 _console <<
"\nNormalizing view factors.\n" << std::endl;
236 min_correction = std::min(correction, min_correction);
237 max_correction = std::max(correction, max_correction);
243 _console <<
"\nFinal view factors.\n" << std::endl;
244 for (
unsigned int from = 0; from <
_n_sides; ++from)
246 std::string from_name;
248 if (pair.second == from)
249 from_name = pair.first;
252 for (
unsigned int to = 0; to <
_n_sides; ++to)
256 if (pair.second == to)
257 to_name = pair.first;
259 _console << from_name <<
" (" << from_id <<
") -> " << to_name <<
" (" << to_id
271 _console << COLOR_CYAN <<
"Summary of the view factor computation" 273 << COLOR_DEFAULT << std::endl;
275 _console <<
"Normalization is performed." << std::endl;
277 _console <<
"Normalization is skipped." << std::endl;
278 _console << std::setw(60) << std::left <<
"Number of patches: " <<
_n_sides << std::endl;
279 _console << std::setw(60) << std::left
280 <<
"Max deviation sum = 1 before normalization: " << max_sum_deviation << std::endl;
281 _console << std::setw(60) << std::left
282 <<
"Max deviation from reciprocity before normalization: " << max_reciprocity_deviation
286 _console << std::setw(60) << std::left <<
"Maximum correction: " << max_correction << std::endl;
287 _console << std::setw(60) << std::left <<
"Minimum correction: " << min_correction << std::endl;
288 _console << std::setw(60) <<
"Max deviation sum = 1 after normalization: " 289 << max_sum_deviation_after_normalization << std::endl;
290 _console << std::setw(60) << std::left <<
"Max deviation from reciprocity after normalization: " 291 << max_reciprocity_deviation_after_normalization << std::endl;
305 for (
unsigned int i = 0; i <
_n_sides; ++i)
317 Real f = 2 * (1 + ar * ar);
318 matrix(i, i) += -1 /
f;
319 matrix(i,
j) += -1 /
f * ar;
324 for (
unsigned int j = 0;
j < i; ++
j)
327 Real f = 2 * (1 + ar * ar);
328 matrix(i, i) += -1 /
f * ar * ar;
329 matrix(i,
j) += -1 /
f * ar;
340 for (
unsigned int i = 0; i <
_n_sides; ++i)
345 correction = -0.5 * lmults(i);
349 Real f = 2 * (1 + ar * ar);
350 correction = -(lmults(i) + lmults(
j) * ar + 2 * ar * ar *
devReciprocity(i,
j)) /
f;
354 vf_temp[i][
j] += correction;
362 for (
unsigned int i = 0; i <
_n_sides; ++i)
373 mooseAssert(i <=
j,
"indexHelper requires i <= j");
377 for (
unsigned int l = 0; l <
_n_sides; ++l)
378 for (
unsigned int m = l + 1; m <
_n_sides; ++m)
380 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 bool _print_view_factor_info
const std::string & getBoundaryName(const BoundaryID boundary_id) const
NormalizationMethod
How to normalize view factors.
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
void normalizeUsingLagrangeMultiplier()
normalizes view factors by Lagrange multiplier method
virtual void execute() override
A base class for automatic computation of view factors between sidesets.
const Real & _current_side_volume
void normalizeUsingInverseRowSum()
normalizes view factors by inverse row sum
const std::string & name() const
const BoundaryID & _current_boundary_id
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
virtual void threadJoin(const UserObject &y) override final
IntRange< T > make_range(T beg, T end)
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
const NormalizationMethod _normalization_method
How to normalize view factors.
Real maxDevReciprocity() const
this function computes the maximum absolute value of the deviation from reciprocity ...
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
virtual void initialize() override