Chi-Tech
sldfe_sq_01_gen_initrefinement.cc
Go to the documentation of this file.
1#include "sldfe_sq.h"
2
3#include "chi_runtime.h"
4#include "chi_log.h"
5
6#include "utils/chi_timer.h"
7
8//###################################################################
9/**Generates uniform spherical quadrilaterals from the
10 * subdivision of an inscribed cube.*/
12{
13 chi::Timer timer;
14 timer.Reset();
15 initial_level_ = level;
16
17 //======================================== Define constants
18 const chi_mesh::Vector3 ihat = chi_mesh::Vector3(1.0,0.0,0.0);
19 const chi_mesh::Vector3 jhat = chi_mesh::Vector3(0.0,1.0,0.0);
20 const chi_mesh::Vector3 khat = chi_mesh::Vector3(0.0,0.0,1.0);
21
22 //======================================== Build rotation matrices
23 // for cube faces
25 Rxface.SetColJVec(0,jhat);
26 Rxface.SetColJVec(1,khat);
27 Rxface.SetColJVec(2,ihat);
28
30 Ryface.SetColJVec(0,ihat);
31 Ryface.SetColJVec(1,khat);
32 Ryface.SetColJVec(2,-1.0*jhat);
33
35 Rzface.SetDiagonalVec(1.0,1.0,1.0);
36
37 //======================================== Set translation vectors
38 // for cube faces
39 auto txface = a*ihat;
40 auto tyface = a*jhat;
41 auto tzface = a*khat;
42
43 //======================================== Generate general diagonal
44 // spacings in xy-tilde coordinates
46
47 //======================================== Generate vertices for each face
48 // of inscribed cube
49 GenerateReferenceFaceVertices(Rxface,txface,level);
50 GenerateReferenceFaceVertices(Ryface,tyface,level);
51 GenerateReferenceFaceVertices(Rzface,tzface,level);
52
53 //======================================== Compute areas
54 double total_area = 0.0;
55 double area_max = -100.0;
56 double area_min = 100.0;
57 bool negative_weights_found = false;
58 for (auto& sq : initial_octant_SQs_)
59 {
60 double area = 0.0;
61 for (int i=0; i<4; ++i)
62 {
63 area += sq.sub_sqr_weights[i];
64 if (area < 0.0) negative_weights_found = true;
65 }
66 total_area += area;
67 area_max = std::fmax(area_max,area);
68 area_min = std::fmin(area_min,area);
69 }
70 double area_avg = total_area / initial_octant_SQs_.size();
71
72 if (negative_weights_found)
74 << "SLDFESQ Quadrature detected negative weights.";
75
76 //======================================== Print Statistics
77 double time = timer.GetTime()/1000.0;
78 Chi::log.Log0Verbose1() << "Number of dirs/octant: " << initial_octant_SQs_.size();
79 Chi::log.Log0Verbose1() << "Total weight : " << total_area;
80 Chi::log.Log0Verbose1() << "Total weight/(pi/2) : " << total_area/M_PI_2;
81 Chi::log.Log0Verbose1() << "Area Max/Min : " << area_max/area_min;
82 Chi::log.Log0Verbose1() << "Area Max/Avg : " << area_max/area_avg;
83
85
86 //======================================== Populate quadriture points
88
89 Chi::log.Log0Verbose1() << "Time taken : " << time;
90}
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream Log0Warning()
Definition: chi_log.h:231
LogStream Log0Verbose1()
Definition: chi_log.h:234
void Reset()
Definition: chi_timer.cc:16
double GetTime() const
Definition: chi_timer.cc:23
std::vector< SphericalQuadrilateral > initial_octant_SQs_
Definition: sldfe_sq.h:73
void GenerateReferenceFaceVertices(const chi_mesh::Matrix3x3 &rotation_matrix, const chi_mesh::Vector3 &translation, int level)
static constexpr double a
Inscribed cude side length.
Definition: sldfe_sq.h:70
VectorN< 3 > Vector3
void SetColJVec(int j, Vector3 vec)
void SetDiagonalVec(double a00, double a11, double a22)