GRINS-0.8.0
List of all members | Public Member Functions | Private Member Functions
GRINSTesting::RayfireTest Class Reference
Inheritance diagram for GRINSTesting::RayfireTest:
Inheritance graph
[legend]
Collaboration diagram for GRINSTesting::RayfireTest:
Collaboration graph
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (RayfireTest)
 
 CPPUNIT_TEST (quad4_all_sides)
 
 CPPUNIT_TEST (quad9_all_sides)
 
 CPPUNIT_TEST (test_slanted_quad4)
 
 CPPUNIT_TEST (test_vertical_fire)
 
 CPPUNIT_TEST (test_quad4_5elem)
 
 CPPUNIT_TEST (test_quad9_5elem)
 
 CPPUNIT_TEST (test_quad4_2D)
 
 CPPUNIT_TEST (test_quad9_2D)
 
 CPPUNIT_TEST (fire_through_vertex)
 
 CPPUNIT_TEST (origin_between_elems)
 
 CPPUNIT_TEST_SUITE_END ()
 
void quad4_all_sides ()
 
void quad9_all_sides ()
 
void test_slanted_quad4 ()
 
void test_vertical_fire ()
 
void test_quad4_5elem ()
 
void test_quad9_5elem ()
 
void test_quad4_2D ()
 
void test_quad9_2D ()
 
void fire_through_vertex ()
 
void origin_between_elems ()
 

Private Member Functions

void run_test (libMesh::Point &origin, libMesh::Real theta, libMesh::Node &calc_end_node, unsigned int n_elem, unsigned int exit_elem, std::string elem_type, unsigned int dim)
 
void run_test_on_all_point_combinations (std::vector< libMesh::Point > pts, GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
 
void run_test_with_mesh (GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh, libMesh::Point &origin, libMesh::Real theta, libMesh::Point &calc_end_point, unsigned int exit_elem)
 
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh (const GetPot &input)
 
libMesh::Real calc_theta (libMesh::Point &start, libMesh::Point end)
 

Detailed Description

Definition at line 56 of file rayfire_test.C.

Member Function Documentation

GRINS::SharedPtr<libMesh::UnstructuredMesh> GRINSTesting::RayfireTest::build_mesh ( const GetPot &  input)
inlineprivate

Definition at line 341 of file rayfire_test.C.

References GRINS::MeshBuilder::build(), and TestCommWorld.

Referenced by run_test().

342  {
343  GRINS::MeshBuilder mesh_builder;
344  return mesh_builder.build( input, *TestCommWorld );
345  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
SharedPtr< libMesh::UnstructuredMesh > build(const GetPot &input, const libMesh::Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
Builds the libMesh::Mesh according to input options.
Definition: mesh_builder.C:46
libMesh::Real GRINSTesting::RayfireTest::calc_theta ( libMesh::Point &  start,
libMesh::Point  end 
)
inlineprivate

Definition at line 347 of file rayfire_test.C.

Referenced by origin_between_elems(), and run_test_on_all_point_combinations().

348  {
349  return std::atan2( (end(1)-start(1)), (end(0)-start(0)) );
350  }
GRINSTesting::RayfireTest::CPPUNIT_TEST ( quad4_all_sides  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( quad9_all_sides  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( test_slanted_quad4  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( test_vertical_fire  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( test_quad4_5elem  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( test_quad9_5elem  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( test_quad4_2D  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( test_quad9_2D  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( fire_through_vertex  )
GRINSTesting::RayfireTest::CPPUNIT_TEST ( origin_between_elems  )
GRINSTesting::RayfireTest::CPPUNIT_TEST_SUITE ( RayfireTest  )
GRINSTesting::RayfireTest::CPPUNIT_TEST_SUITE_END ( )
void GRINSTesting::RayfireTest::fire_through_vertex ( )
inline

Definition at line 262 of file rayfire_test.C.

References GRINS::Constants::pi, and run_test().

263  {
264  libMesh::Point origin = libMesh::Point(0.0,0.0);
265 
266  libMesh::Node calc_end_node_straight = libMesh::Node(3.0,3.0);
267 
268  // 3x3 QUAD4 mesh
269  this->run_test(origin,45.0*GRINS::Constants::pi/180.0,calc_end_node_straight,9,8,"quad4",2);
270 
271  // 3x3 QUAD9 mesh
272  this->run_test(origin,45.0*GRINS::Constants::pi/180.0,calc_end_node_straight,9,8,"quad9",2);
273  }
const libMesh::Real pi
void run_test(libMesh::Point &origin, libMesh::Real theta, libMesh::Node &calc_end_node, unsigned int n_elem, unsigned int exit_elem, std::string elem_type, unsigned int dim)
Definition: rayfire_test.C:288
void GRINSTesting::RayfireTest::origin_between_elems ( )
inline

Definition at line 275 of file rayfire_test.C.

References calc_theta(), and run_test().

276  {
277  libMesh::Point origin = libMesh::Point(0.0,1.0);
278  libMesh::Node calc_end_node = libMesh::Node(3.0,3.0);
279  libMesh::Real theta = calc_theta(origin,calc_end_node);
280 
281  this->run_test(origin,theta,calc_end_node,9,8,"quad4",2);
282  this->run_test(origin,theta,calc_end_node,9,8,"quad9",2);
283  }
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
Definition: rayfire_test.C:347
void run_test(libMesh::Point &origin, libMesh::Real theta, libMesh::Node &calc_end_node, unsigned int n_elem, unsigned int exit_elem, std::string elem_type, unsigned int dim)
Definition: rayfire_test.C:288
void GRINSTesting::RayfireTest::quad4_all_sides ( )
inline

Definition at line 76 of file rayfire_test.C.

References run_test_on_all_point_combinations(), and TestCommWorld.

77  {
78  // vector of intersection points
79  std::vector<libMesh::Point> pts(4);
80  pts[0] = libMesh::Point(0.0,0.5);
81  pts[1] = libMesh::Point(0.915243860856226,0.0);
82  pts[2] = libMesh::Point(1.0,0.25);
83  pts[3] = libMesh::Point(0.321046307967165,1.0);
84 
85  // create the mesh (single square QUAD4 element)
86  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
87 
88  mesh->set_mesh_dimension(2);
89 
90  mesh->add_point( libMesh::Point(0.0,0.0),0 );
91  mesh->add_point( libMesh::Point(1.0,0.0),1 );
92  mesh->add_point( libMesh::Point(1.0,1.0),2 );
93  mesh->add_point( libMesh::Point(0.0,1.0),3 );
94 
95  libMesh::Elem* elem = mesh->add_elem( new libMesh::Quad4 );
96  for (unsigned int n=0; n<4; n++)
97  elem->set_node(n) = mesh->node_ptr(n);
98 
99  mesh->prepare_for_use();
100 
102 
103  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
void run_test_on_all_point_combinations(std::vector< libMesh::Point > pts, GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
Definition: rayfire_test.C:300
void GRINSTesting::RayfireTest::quad9_all_sides ( )
inline

Definition at line 105 of file rayfire_test.C.

References run_test_on_all_point_combinations(), and TestCommWorld.

106  {
107  // vector of intersection points
108  std::vector<libMesh::Point> pts(4);
109  pts[0] = libMesh::Point(0.0,0.5);
110  pts[1] = libMesh::Point(0.915243860856226,0.0);
111  pts[2] = libMesh::Point(1.375,0.25);
112  pts[3] = libMesh::Point(0.321046307967165,1.0);
113 
114  // create a non-rectangular QUAD9
115  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
116 
117  mesh->set_mesh_dimension(2);
118 
119  mesh->add_point( libMesh::Point(0.0,0.0),0 );
120  mesh->add_point( libMesh::Point(1.0,0.0),1 );
121  mesh->add_point( libMesh::Point(1.0,1.0),2 );
122  mesh->add_point( libMesh::Point(0.0,1.0),3 );
123  mesh->add_point( libMesh::Point(0.5,0.0),4 );
124  mesh->add_point( libMesh::Point(1.5,0.5),5 );
125  mesh->add_point( libMesh::Point(0.5,1.0),6 );
126  mesh->add_point( libMesh::Point(0.0,0.5),7 );
127  mesh->add_point( libMesh::Point(0.5,0.5),8 );
128 
129  libMesh::Elem* elem = mesh->add_elem( new libMesh::Quad9 );
130  for (unsigned int n=0; n<9; n++)
131  elem->set_node(n) = mesh->node_ptr(n);
132 
133  mesh->prepare_for_use();
134 
136 
137  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
void run_test_on_all_point_combinations(std::vector< libMesh::Point > pts, GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
Definition: rayfire_test.C:300
void GRINSTesting::RayfireTest::run_test ( libMesh::Point &  origin,
libMesh::Real  theta,
libMesh::Node &  calc_end_node,
unsigned int  n_elem,
unsigned int  exit_elem,
std::string  elem_type,
unsigned int  dim 
)
inlineprivate

Definition at line 288 of file rayfire_test.C.

References build_mesh(), and run_test_with_mesh().

Referenced by fire_through_vertex(), origin_between_elems(), test_quad4_2D(), test_quad4_5elem(), test_quad9_2D(), and test_quad9_5elem().

289  {
290  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_"+elem_type+"_"+std::to_string(n_elem)+"elem_"+std::to_string(dim)+"D.in";
291  GetPot input(filename);
292  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
293 
294  // ensure the mesh has the desired number of elements
295  CPPUNIT_ASSERT_EQUAL(n_elem,mesh->n_elem());
296 
297  run_test_with_mesh(mesh,origin,theta,calc_end_node,exit_elem);
298  }
void run_test_with_mesh(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh, libMesh::Point &origin, libMesh::Real theta, libMesh::Point &calc_end_point, unsigned int exit_elem)
Definition: rayfire_test.C:325
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
Definition: rayfire_test.C:341
void GRINSTesting::RayfireTest::run_test_on_all_point_combinations ( std::vector< libMesh::Point >  pts,
GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh 
)
inlineprivate

Definition at line 300 of file rayfire_test.C.

References calc_theta(), and run_test_with_mesh().

Referenced by quad4_all_sides(), quad9_all_sides(), and test_slanted_quad4().

301  {
302  // iterate over the starting points
303  for(unsigned int i=0; i<pts.size(); i++)
304  {
305  libMesh::Point start_point = pts[i];
306 
307  // iterate over all the intersection points
308  for(unsigned int j=0; j<pts.size(); j++)
309  {
310  if(j==i)
311  continue;
312 
313  libMesh::Point end_point = pts[j];
314 
315  libMesh::Real theta = calc_theta(start_point,end_point);
316 
317  // run the test
318  this->run_test_with_mesh(mesh,start_point,theta,end_point,0);
319  }
320 
321  }
322 
323  }
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
Definition: rayfire_test.C:347
void run_test_with_mesh(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh, libMesh::Point &origin, libMesh::Real theta, libMesh::Point &calc_end_point, unsigned int exit_elem)
Definition: rayfire_test.C:325
void GRINSTesting::RayfireTest::run_test_with_mesh ( GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh,
libMesh::Point &  origin,
libMesh::Real  theta,
libMesh::Point &  calc_end_point,
unsigned int  exit_elem 
)
inlineprivate

Definition at line 325 of file rayfire_test.C.

Referenced by run_test(), run_test_on_all_point_combinations(), and test_vertical_fire().

326  {
327  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
328  rayfire->init(*mesh);
329 
330  const libMesh::Elem* original_elem = mesh->elem_ptr(exit_elem);
331 
332  const libMesh::Elem* rayfire_elem = rayfire->map_to_rayfire_elem(original_elem->id());
333 
334  if (!rayfire_elem)
335  libmesh_error_msg("Attempted to map an element that is not in the Rayfire");
336 
337  CPPUNIT_ASSERT_DOUBLES_EQUAL(calc_end_point(0), (*(rayfire_elem->node_ptr(1)))(0),libMesh::TOLERANCE);
338  CPPUNIT_ASSERT_DOUBLES_EQUAL(calc_end_point(1), (*(rayfire_elem->node_ptr(1)))(1),libMesh::TOLERANCE);
339  }
RayfireMesh.
Definition: rayfire_mesh.h:65
void GRINSTesting::RayfireTest::test_quad4_2D ( )
inline

Definition at line 222 of file rayfire_test.C.

References run_test().

223  {
224  libMesh::Point origin = libMesh::Point(0.0,1.5);
225 
226  libMesh::Node calc_end_node_straight = libMesh::Node(3.0,1.5);
227  this->run_test(origin,0.0,calc_end_node_straight,9,5,"quad4",2);
228 
229  libMesh::Node calc_end_node_small_angle = libMesh::Node(3.0,1.5+3.0*std::tan(0.15));
230  this->run_test(origin,0.15,calc_end_node_small_angle,9,5,"quad4",2);
231 
232  libMesh::Node calc_end_node_small_neg_angle = libMesh::Node(3.0,1.5+3.0*std::tan(-0.15));
233  this->run_test(origin,-0.15,calc_end_node_small_neg_angle,9,5,"quad4",2);
234 
235  libMesh::Node calc_end_node_large_angle = libMesh::Node( (3.0-1.5)/std::tan(1.0), 3.0);
236  this->run_test(origin,1.0,calc_end_node_large_angle,9,6,"quad4",2);
237 
238  libMesh::Node calc_end_node_large_neg_angle = libMesh::Node( (0.0-1.5)/std::tan(-1.0), 0.0);
239  this->run_test(origin,-1.0,calc_end_node_large_neg_angle,9,0,"quad4",2);
240  }
void run_test(libMesh::Point &origin, libMesh::Real theta, libMesh::Node &calc_end_node, unsigned int n_elem, unsigned int exit_elem, std::string elem_type, unsigned int dim)
Definition: rayfire_test.C:288
void GRINSTesting::RayfireTest::test_quad4_5elem ( )
inline

Definition at line 194 of file rayfire_test.C.

References run_test().

195  {
196  libMesh::Point origin = libMesh::Point(0,0.5);
197 
198  libMesh::Node calc_end_node_straight = libMesh::Node(5.0,0.5);
199  this->run_test(origin,0.0,calc_end_node_straight,5,4,"quad4",1);
200 
201  libMesh::Node calc_end_node_angle = libMesh::Node(0.5/std::tan(0.15),1.0);
202  this->run_test(origin,0.15,calc_end_node_angle,5,3,"quad4",1);
203 
204  libMesh::Node calc_end_node_neg_angle = libMesh::Node(0.5/std::tan(0.15),0.0);
205  this->run_test(origin,-0.15,calc_end_node_neg_angle,5,3,"quad4",1);
206  }
void run_test(libMesh::Point &origin, libMesh::Real theta, libMesh::Node &calc_end_node, unsigned int n_elem, unsigned int exit_elem, std::string elem_type, unsigned int dim)
Definition: rayfire_test.C:288
void GRINSTesting::RayfireTest::test_quad9_2D ( )
inline

Definition at line 242 of file rayfire_test.C.

References run_test().

243  {
244  libMesh::Point origin = libMesh::Point(0.0,1.5);
245 
246  libMesh::Node calc_end_node_straight = libMesh::Node(3.0,1.5);
247  this->run_test(origin,0.0,calc_end_node_straight,9,5,"quad9",2);
248 
249  libMesh::Node calc_end_node_small_angle = libMesh::Node(3.0,1.5+3.0*std::tan(0.15));
250  this->run_test(origin,0.15,calc_end_node_small_angle,9,5,"quad9",2);
251 
252  libMesh::Node calc_end_node_small_neg_angle = libMesh::Node(3.0,1.5+3.0*std::tan(-0.15));
253  this->run_test(origin,-0.15,calc_end_node_small_neg_angle,9,5,"quad9",2);
254 
255  libMesh::Node calc_end_node_large_angle = libMesh::Node( (3.0-1.5)/std::tan(1.0), 3.0);
256  this->run_test(origin,1.0,calc_end_node_large_angle,9,6,"quad9",2);
257 
258  libMesh::Node calc_end_node_large_neg_angle = libMesh::Node( (0.0-1.5)/std::tan(-1.0), 0.0);
259  this->run_test(origin,-1.0,calc_end_node_large_neg_angle,9,0,"quad9",2);
260  }
void run_test(libMesh::Point &origin, libMesh::Real theta, libMesh::Node &calc_end_node, unsigned int n_elem, unsigned int exit_elem, std::string elem_type, unsigned int dim)
Definition: rayfire_test.C:288
void GRINSTesting::RayfireTest::test_quad9_5elem ( )
inline

Definition at line 208 of file rayfire_test.C.

References run_test().

209  {
210  libMesh::Point origin = libMesh::Point(0,0.5);
211 
212  libMesh::Node calc_end_node_straight = libMesh::Node(5.0,0.5);
213  this->run_test(origin,0.0,calc_end_node_straight,5,4,"quad9",1);
214 
215  libMesh::Node calc_end_node_angle = libMesh::Node(0.5/std::tan(0.15),1.0);
216  this->run_test(origin,0.15,calc_end_node_angle,5,3,"quad9",1);
217 
218  libMesh::Node calc_end_node_neg_angle = libMesh::Node(0.5/std::tan(0.15),0.0);
219  this->run_test(origin,-0.15,calc_end_node_neg_angle,5,3,"quad9",1);
220  }
void run_test(libMesh::Point &origin, libMesh::Real theta, libMesh::Node &calc_end_node, unsigned int n_elem, unsigned int exit_elem, std::string elem_type, unsigned int dim)
Definition: rayfire_test.C:288
void GRINSTesting::RayfireTest::test_slanted_quad4 ( )
inline

Definition at line 139 of file rayfire_test.C.

References run_test_on_all_point_combinations(), and TestCommWorld.

140  {
141  // vector of intersection points
142  std::vector<libMesh::Point> pts(4);
143  pts[0] = libMesh::Point(0.5,0.0);
144  pts[1] = libMesh::Point(1.75,0.75);
145  pts[2] = libMesh::Point(1.5,0.9);
146  pts[3] = libMesh::Point(-0.1,0.1);
147 
148  // create the mesh (single trapezoidal QUAD4 element)
149  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
150 
151  mesh->set_mesh_dimension(2);
152 
153  mesh->add_point( libMesh::Point(0.0,0.0),0 );
154  mesh->add_point( libMesh::Point(1.0,0.0),1 );
155  mesh->add_point( libMesh::Point(2.0,1.0),2 );
156  mesh->add_point( libMesh::Point(-0.5,0.5),3 );
157 
158  libMesh::Elem* elem = mesh->add_elem( new libMesh::Quad4 );
159  for (unsigned int n=0; n<4; n++)
160  elem->set_node(n) = mesh->node_ptr(n);
161 
162  mesh->prepare_for_use();
163 
165 
166  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
void run_test_on_all_point_combinations(std::vector< libMesh::Point > pts, GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
Definition: rayfire_test.C:300
void GRINSTesting::RayfireTest::test_vertical_fire ( )
inline

Definition at line 168 of file rayfire_test.C.

References GRINS::Constants::pi, run_test_with_mesh(), and TestCommWorld.

169  {
170  // create the mesh (single square QUAD4 element)
171  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
172 
173  mesh->set_mesh_dimension(2);
174 
175  mesh->add_point( libMesh::Point(0.0,0.0),0 );
176  mesh->add_point( libMesh::Point(1.0,0.0),1 );
177  mesh->add_point( libMesh::Point(1.0,1.0),2 );
178  mesh->add_point( libMesh::Point(0.0,1.0),3 );
179 
180  libMesh::Elem* elem = mesh->add_elem( new libMesh::Quad4 );
181  for (unsigned int n=0; n<4; n++)
182  elem->set_node(n) = mesh->node_ptr(n);
183 
184  mesh->prepare_for_use();
185 
186  libMesh::Point start_point(0.3,0.0);
187  libMesh::Point end_point(0.3,1.0);
188 
189  libMesh::Real theta = GRINS::Constants::pi/2.0;
190 
191  this->run_test_with_mesh(mesh,start_point,theta,end_point,0);
192  }
void run_test_with_mesh(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh, libMesh::Point &origin, libMesh::Real theta, libMesh::Point &calc_end_point, unsigned int exit_elem)
Definition: rayfire_test.C:325
const libMesh::Real pi
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70

The documentation for this class was generated from the following file:

Generated on Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1