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

Public Member Functions

 CPPUNIT_TEST_SUITE (RayfireTestAMR)
 
 CPPUNIT_TEST (single_elems)
 
 CPPUNIT_TEST (through_vertex_postrefinment)
 
 CPPUNIT_TEST (near_vertex_postrefinement)
 
 CPPUNIT_TEST (large_2D_mesh)
 
 CPPUNIT_TEST (refine_elem_not_on_rayfire)
 
 CPPUNIT_TEST (multiple_refinements)
 
 CPPUNIT_TEST (coarsen_elements)
 
 CPPUNIT_TEST (refine_and_coarsen)
 
 CPPUNIT_TEST (mixed_type_mesh)
 
 CPPUNIT_TEST (start_with_refined_mesh)
 
 CPPUNIT_TEST (refined_above_unrefined)
 
 CPPUNIT_TEST (refine_deformed_elem)
 
 CPPUNIT_TEST (refine_deformed_elem_near_tolerance)
 
 CPPUNIT_TEST (init_on_refined_mesh)
 
 CPPUNIT_TEST_SUITE_END ()
 
void single_elems ()
 Refine a single element. More...
 
void through_vertex_postrefinment ()
 After refinement, the rayfire will travel through a vertex. More...
 
void near_vertex_postrefinement ()
 After refinement, the rayfire will travel very near (but not through) a vertex. More...
 
void large_2D_mesh ()
 A 10x10 mesh with selectively refined elements. More...
 
void refine_elem_not_on_rayfire ()
 Make sure refined elements not on the rayfire do not get added. More...
 
void multiple_refinements ()
 Test for multiple successive refinements. More...
 
void coarsen_elements ()
 Test of the coarsening functionality. More...
 
void refine_and_coarsen ()
 Refine and coarsen before calling reinit() More...
 
void mixed_type_mesh ()
 Mesh contains 2 QUAD4 and 2 TRI3. More...
 
void start_with_refined_mesh ()
 Mesh given to init() is already refined. More...
 
void refined_above_unrefined ()
 2 QUAD4 elems, one is refined, one if not, rayfire travels boundary between them More...
 
void refine_deformed_elem ()
 QUAD4 elem is deformed, rayfire goes within libMesh::TOLERANCE central node. More...
 
void refine_deformed_elem_near_tolerance ()
 
void init_on_refined_mesh ()
 

Private Member Functions

libMesh::Real calc_theta (libMesh::Point &start, libMesh::Point end)
 
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh (const GetPot &input)
 
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad4_elem ()
 Build a single square QUAD4. More...
 
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad9_elem ()
 Build a single square QUAD9. More...
 
void test_single_elem (GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
 Runs the test on single square QUADs of unit length and width. More...
 
void test_through_vertex (GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
 
void test_near_vertex (GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
 
void test_large_mesh (GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
 Refine specific elements on a large mesh. More...
 
void test_multiple_refinements (GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
 Refine the mesh 3 times. More...
 
void test_coarsen (GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
 Test coarsening specific elements on a large mesh. More...
 
void test_deformed_elem (GRINS::SharedPtr< libMesh::UnstructuredMesh > &mesh, libMesh::Point &origin, libMesh::Real theta, std::vector< unsigned int > &children_in_rayfire, std::vector< unsigned int > &children_not_in_rayfire)
 

Detailed Description

Definition at line 57 of file rayfireAMR_test.C.

Member Function Documentation

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

Definition at line 503 of file rayfireAMR_test.C.

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

Referenced by coarsen_elements(), init_on_refined_mesh(), large_2D_mesh(), mixed_type_mesh(), and refine_elem_not_on_rayfire().

504  {
505  GRINS::MeshBuilder mesh_builder;
506  return mesh_builder.build( input, *TestCommWorld );
507  }
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
GRINS::SharedPtr<libMesh::UnstructuredMesh> GRINSTesting::RayfireTestAMR::build_quad4_elem ( )
inlineprivate

Build a single square QUAD4.

Definition at line 510 of file rayfireAMR_test.C.

References TestCommWorld.

Referenced by multiple_refinements(), near_vertex_postrefinement(), refine_and_coarsen(), single_elems(), start_with_refined_mesh(), and through_vertex_postrefinment().

511  {
512  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
513 
514  mesh->set_mesh_dimension(2);
515 
516  mesh->add_point( libMesh::Point(0.0,0.0),0 );
517  mesh->add_point( libMesh::Point(1.0,0.0),1 );
518  mesh->add_point( libMesh::Point(1.0,1.0),2 );
519  mesh->add_point( libMesh::Point(0.0,1.0),3 );
520 
521  libMesh::Elem* elem = mesh->add_elem( new libMesh::Quad4 );
522  for (unsigned int n=0; n<4; n++)
523  elem->set_node(n) = mesh->node_ptr(n);
524 
525  mesh->prepare_for_use();
526 
527  return mesh;
528  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
GRINS::SharedPtr<libMesh::UnstructuredMesh> GRINSTesting::RayfireTestAMR::build_quad9_elem ( )
inlineprivate

Build a single square QUAD9.

Definition at line 531 of file rayfireAMR_test.C.

References TestCommWorld.

Referenced by multiple_refinements(), near_vertex_postrefinement(), single_elems(), and through_vertex_postrefinment().

532  {
533  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
534 
535  mesh->set_mesh_dimension(2);
536 
537  mesh->add_point( libMesh::Point(0.0,0.0),0 );
538  mesh->add_point( libMesh::Point(1.0,0.0),1 );
539  mesh->add_point( libMesh::Point(1.0,1.0),2 );
540  mesh->add_point( libMesh::Point(0.0,1.0),3 );
541  mesh->add_point( libMesh::Point(0.5,0.0),4 );
542  mesh->add_point( libMesh::Point(1.0,0.5),5 );
543  mesh->add_point( libMesh::Point(0.5,1.0),6 );
544  mesh->add_point( libMesh::Point(0.0,0.5),7 );
545  mesh->add_point( libMesh::Point(0.5,0.5),8 );
546 
547  libMesh::Elem* elem = mesh->add_elem( new libMesh::Quad9 );
548  for (unsigned int n=0; n<9; n++)
549  elem->set_node(n) = mesh->node_ptr(n);
550 
551  mesh->prepare_for_use();
552 
553  return mesh;
554  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
libMesh::Real GRINSTesting::RayfireTestAMR::calc_theta ( libMesh::Point &  start,
libMesh::Point  end 
)
inlineprivate

Definition at line 498 of file rayfireAMR_test.C.

Referenced by mixed_type_mesh(), refine_and_coarsen(), refine_elem_not_on_rayfire(), start_with_refined_mesh(), test_coarsen(), test_large_mesh(), test_multiple_refinements(), test_near_vertex(), test_single_elem(), and test_through_vertex().

499  {
500  return std::atan2( (end(1)-start(1)), (end(0)-start(0)) );
501  }
void GRINSTesting::RayfireTestAMR::coarsen_elements ( )
inline

Test of the coarsening functionality.

Definition at line 166 of file rayfireAMR_test.C.

References build_mesh(), and test_coarsen().

167  {
168  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_quad4_100elem_2D.in";
169  GetPot input_quad4(filename);
170  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input_quad4);
171  test_coarsen(mesh);
172 
173  filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_quad9_100elem_2D.in";
174  GetPot input_quad9(filename);
175  mesh = this->build_mesh(input_quad9);
176  test_coarsen(mesh);
177  }
void test_coarsen(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
Test coarsening specific elements on a large mesh.
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( single_elems  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( through_vertex_postrefinment  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( near_vertex_postrefinement  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( large_2D_mesh  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( refine_elem_not_on_rayfire  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( multiple_refinements  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( coarsen_elements  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( refine_and_coarsen  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( mixed_type_mesh  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( start_with_refined_mesh  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( refined_above_unrefined  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( refine_deformed_elem  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( refine_deformed_elem_near_tolerance  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST ( init_on_refined_mesh  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST_SUITE ( RayfireTestAMR  )
GRINSTesting::RayfireTestAMR::CPPUNIT_TEST_SUITE_END ( )
void GRINSTesting::RayfireTestAMR::init_on_refined_mesh ( )
inline

Call init() on an already refined mesh

Mimics a run from restart

Definition at line 463 of file rayfireAMR_test.C.

References build_mesh().

464  {
465  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_quad4_9elem_2D.in";
466  GetPot input_quad4(filename);
467  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input_quad4);
468 
469  // refine elem 1 before rayfire init
470  libMesh::MeshRefinement mr(*mesh);
471  mesh->elem_ptr(1)->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
472  mr.refine_elements();
473 
474  CPPUNIT_ASSERT( !(mesh->elem_ptr(1)->active()) );
475  CPPUNIT_ASSERT( mesh->elem_ptr(1)->has_children() );
476 
477  libMesh::Point origin(0.0,0.1);
478  libMesh::Real theta = 0.0;
479 
480  // initialize the rayfire
481  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
482  rayfire->init(*mesh);
483 
484  // make sure we pick up the 2 unrefined elements
485  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(0) );
486  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(2) );
487 
488  // rayfire should not include elem 1 since it's INACTIVE
489  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(1)) );
490 
491  // rayfire should contain children 0,1 of elem 1
492  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ref(1).child_ptr(0)->id()) );
493  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ref(1).child_ptr(1)->id()) );
494  }
RayfireMesh.
Definition: rayfire_mesh.h:65
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
void GRINSTesting::RayfireTestAMR::large_2D_mesh ( )
inline

A 10x10 mesh with selectively refined elements.

Definition at line 112 of file rayfireAMR_test.C.

References build_mesh(), and test_large_mesh().

113  {
114  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_quad4_100elem_2D.in";
115  GetPot input_quad4(filename);
116  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input_quad4);
117  test_large_mesh(mesh);
118 
119  filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_quad9_100elem_2D.in";
120  GetPot input_quad9(filename);
121  mesh = this->build_mesh(input_quad9);
122  test_large_mesh(mesh);
123  }
void test_large_mesh(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
Refine specific elements on a large mesh.
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
void GRINSTesting::RayfireTestAMR::mixed_type_mesh ( )
inline

Mesh contains 2 QUAD4 and 2 TRI3.

Definition at line 217 of file rayfireAMR_test.C.

References build_mesh(), and calc_theta().

218  {
219  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mixed_quad_tri.in";
220  GetPot input(filename);
221  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
222 
223  libMesh::Point origin(0.0,0.25);
224  libMesh::Point end_point(1.0,0.25);
225  libMesh::Real theta = calc_theta(origin,end_point);
226 
227  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
228  rayfire->init(*mesh);
229 
230  // check that the rayfire is through the right elems
231  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(0) );
232  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(6) );
233  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(9) );
234  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(8) );
235 
236  // and not through others
237  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(2)) );
238  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(3)) );
239  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(4)) );
240  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(5)) );
241  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(1)) );
242  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(7)) );
243 
244  // now do a uniform refinement
245  libMesh::MeshRefinement mr(*mesh);
246  mr.uniformly_refine();
247 
248  rayfire->reinit(*mesh);
249 
250  // check post-refinement
251  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->id()) );
252  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->id()) );
253  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(6)->child_ptr(0)->id()) );
254  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(9)->child_ptr(1)->id()) );
255  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(8)->child_ptr(2)->id()) );
256 
257  // coarsen two of the TRIs
258  for (unsigned int c=0; c<mesh->elem_ptr(6)->n_children(); c++)
259  {
260  mesh->elem_ptr(6)->child_ptr(c)->set_refinement_flag(libMesh::Elem::RefinementState::COARSEN);
261  mesh->elem_ptr(9)->child_ptr(c)->set_refinement_flag(libMesh::Elem::RefinementState::COARSEN);
262  }
263 
264  mr.coarsen_elements();
265  rayfire->reinit(*mesh);
266 
267  CPPUNIT_ASSERT( mesh->elem_ptr(6)->active() );
268  CPPUNIT_ASSERT( mesh->elem_ptr(9)->active() );
269 
270  // check post-coarsen
271  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->id()) );
272  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->id()) );
273  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(8)->child_ptr(2)->id()) );
274  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(6) );
275  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(9) );
276 
277  for (unsigned int c=0; c<mesh->elem_ptr(6)->n_children(); c++)
278  {
279  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(6)->child_ptr(c)->id())) );
280  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(9)->child_ptr(c)->id())) );
281  }
282  }
RayfireMesh.
Definition: rayfire_mesh.h:65
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::multiple_refinements ( )
inline

Test for multiple successive refinements.

Definition at line 156 of file rayfireAMR_test.C.

References build_quad4_elem(), build_quad9_elem(), and test_multiple_refinements().

157  {
158  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = build_quad4_elem();
160 
161  mesh = build_quad9_elem();
163  }
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad9_elem()
Build a single square QUAD9.
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad4_elem()
Build a single square QUAD4.
void test_multiple_refinements(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
Refine the mesh 3 times.
void GRINSTesting::RayfireTestAMR::near_vertex_postrefinement ( )
inline

After refinement, the rayfire will travel very near (but not through) a vertex.

Definition at line 102 of file rayfireAMR_test.C.

References build_quad4_elem(), build_quad9_elem(), and test_near_vertex().

103  {
104  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = build_quad4_elem();
105  test_near_vertex(mesh);
106 
107  mesh = build_quad9_elem();
108  test_near_vertex(mesh);
109  }
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad9_elem()
Build a single square QUAD9.
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad4_elem()
Build a single square QUAD4.
void test_near_vertex(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
void GRINSTesting::RayfireTestAMR::refine_and_coarsen ( )
inline

Refine and coarsen before calling reinit()

Definition at line 180 of file rayfireAMR_test.C.

References build_quad4_elem(), and calc_theta().

181  {
182  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = build_quad4_elem();
183 
184  libMesh::Point origin(0.0,0.1);
185  libMesh::Point end_point(1.0,0.1);
186  libMesh::Real theta = calc_theta(origin,end_point);
187 
188  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
189  rayfire->init(*mesh);
190 
191  libMesh::MeshRefinement mr(*mesh);
192  mr.uniformly_refine();
193  rayfire->reinit(*mesh);
194  mr.uniformly_refine();
195  rayfire->reinit(*mesh);
196 
197  // refine elem(0)->child_ptr(1)->child_ptr(1)
198  mesh->elem_ptr(0)->child_ptr(1)->child_ptr(1)->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
199  // coarsen elem(0)->child_ptr(0)
200  for (unsigned int c=0; c<mesh->elem_ptr(0)->child_ptr(0)->n_children(); c++)
201  mesh->elem_ptr(0)->child_ptr(0)->child_ptr(c)->set_refinement_flag(libMesh::Elem::RefinementState::COARSEN);
202 
203  mr.refine_and_coarsen_elements();
204  rayfire->reinit(*mesh);
205 
206  CPPUNIT_ASSERT( mesh->elem_ptr(0)->child_ptr(0)->active() );
207 
208  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->id()) );
209  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(0)->id()) );
210  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(1)->child_ptr(0)->id()) );
211  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(1)->child_ptr(1)->id()) );
212 
213 
214  }
RayfireMesh.
Definition: rayfire_mesh.h:65
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad4_elem()
Build a single square QUAD4.
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::refine_deformed_elem ( )
inline

QUAD4 elem is deformed, rayfire goes within libMesh::TOLERANCE central node.

Definition at line 385 of file rayfireAMR_test.C.

References test_deformed_elem(), and TestCommWorld.

386  {
387  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
388 
389  mesh->set_mesh_dimension(2);
390 
391  mesh->add_point( libMesh::Point(0.0,0.0),0 );
392  mesh->add_point( libMesh::Point(1.0,0.0),1 );
393  mesh->add_point( libMesh::Point(1.1,1.1),2 );
394  mesh->add_point( libMesh::Point(0.2,1.0),3 );
395 
396  libMesh::Elem* e = mesh->add_elem( new libMesh::Quad4 );
397  for (unsigned int n=0; n<4; n++)
398  e->set_node(n) = mesh->node_ptr(n);
399 
400  mesh->prepare_for_use();
401 
402  CPPUNIT_ASSERT_EQUAL( mesh->n_elem(), (libMesh::dof_id_type)1 );
403 
404  libMesh::Real y = 0.5250005;
405  libMesh::Real x = y/5.0;
406 
407  libMesh::Point origin(x,y); // within libMesh::TOLERANCE of node 8
408  libMesh::Real theta = 0.0;
409 
410  std::vector<unsigned int> children_in_rayfire;
411  children_in_rayfire.push_back(1);
412  children_in_rayfire.push_back(2);
413  children_in_rayfire.push_back(3);
414 
415  std::vector<unsigned int> children_not_in_rayfire;
416  children_not_in_rayfire.push_back(0);
417 
418  this->test_deformed_elem(mesh,origin,theta,children_in_rayfire,children_not_in_rayfire);
419  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
void test_deformed_elem(GRINS::SharedPtr< libMesh::UnstructuredMesh > &mesh, libMesh::Point &origin, libMesh::Real theta, std::vector< unsigned int > &children_in_rayfire, std::vector< unsigned int > &children_not_in_rayfire)
void GRINSTesting::RayfireTestAMR::refine_deformed_elem_near_tolerance ( )
inline

QUAD4 elem is slightly deformed, rayfire starts and ends very neay boundary of refined children.

Based on an element from a larger mesh, hence the seemingly arbitrary coordinates

Definition at line 424 of file rayfireAMR_test.C.

References test_deformed_elem(), and TestCommWorld.

425  {
426  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
427 
428  mesh->set_mesh_dimension(2);
429 
430  mesh->add_point( libMesh::Point(0.26591876082146976,0.016285303166482301),2 );
431  mesh->add_point( libMesh::Point(0.26539426622418877,0.016285726631637167),3 );
432  mesh->add_point( libMesh::Point(0.26538091506882988,0.015714299294800886),0 );
433  mesh->add_point( libMesh::Point(0.26590538328042834,0.015713833483130532),1 );
434 
435  libMesh::Elem* e = mesh->add_elem( new libMesh::Quad4 );
436  for (unsigned int n=0; n<4; n++)
437  e->set_node(n) = mesh->node_ptr(n);
438 
439  mesh->prepare_for_use();
440 
441  CPPUNIT_ASSERT_EQUAL( mesh->n_elem(), (libMesh::dof_id_type)1 );
442 
443  libMesh::Real x = 0.26538759034362924;
444  libMesh::Real y = 0.01600000000000000;
445 
446  libMesh::Point origin(x,y);
447  libMesh::Real theta = 0.0;
448 
449  std::vector<unsigned int> children_in_rayfire;
450  children_in_rayfire.push_back(0);
451  children_in_rayfire.push_back(2);
452  children_in_rayfire.push_back(3);
453 
454  std::vector<unsigned int> children_not_in_rayfire;
455  children_not_in_rayfire.push_back(1);
456 
457  this->test_deformed_elem(mesh,origin,theta,children_in_rayfire,children_not_in_rayfire);
458  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
void test_deformed_elem(GRINS::SharedPtr< libMesh::UnstructuredMesh > &mesh, libMesh::Point &origin, libMesh::Real theta, std::vector< unsigned int > &children_in_rayfire, std::vector< unsigned int > &children_not_in_rayfire)
void GRINSTesting::RayfireTestAMR::refine_elem_not_on_rayfire ( )
inline

Make sure refined elements not on the rayfire do not get added.

Definition at line 126 of file rayfireAMR_test.C.

References build_mesh(), and calc_theta().

127  {
128  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_quad4_100elem_2D.in";
129  GetPot input(filename);
130  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
131 
132  libMesh::Point origin(0.0,6.5);
133  libMesh::Point end_point(10.0,0.25);
134  libMesh::Real theta = calc_theta(origin,end_point);
135 
136  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
137  rayfire->init(*mesh);
138 
139  // elem 0 is not along the rayfire
140  mesh->elem_ptr(0)->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
141 
142  libMesh::MeshRefinement mr(*mesh);
143  mr.refine_elements();
144 
145  rayfire->reinit(*mesh);
146 
147  // elem 0 should not be in the rayfire
148  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->id()) ) );
149 
150  // no children of elem 0 should be in the rayfire
151  for (unsigned int i=0; i<4; i++)
152  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem( mesh->elem_ptr(0)->child_ptr(i)->id() ) ) );
153  }
RayfireMesh.
Definition: rayfire_mesh.h:65
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::refined_above_unrefined ( )
inline

2 QUAD4 elems, one is refined, one if not, rayfire travels boundary between them

Definition at line 334 of file rayfireAMR_test.C.

References TestCommWorld.

334  {
335  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = new libMesh::SerialMesh(*TestCommWorld);
336 
337  mesh->set_mesh_dimension(2);
338 
339  mesh->add_point( libMesh::Point(0.0,0.0),0 );
340  mesh->add_point( libMesh::Point(1.0,0.0),1 );
341  mesh->add_point( libMesh::Point(1.0,1.0),2 );
342  mesh->add_point( libMesh::Point(0.0,1.0),3 );
343  mesh->add_point( libMesh::Point(1.0,2.0),4 );
344  mesh->add_point( libMesh::Point(0.0,2.0),5 );
345 
346  libMesh::Elem* elem0 = mesh->add_elem( new libMesh::Quad4 );
347  elem0->set_node(0) = mesh->node_ptr(0);
348  elem0->set_node(1) = mesh->node_ptr(1);
349  elem0->set_node(2) = mesh->node_ptr(2);
350  elem0->set_node(3) = mesh->node_ptr(3);
351 
352  libMesh::Elem* elem1 = mesh->add_elem( new libMesh::Quad4 );
353  elem1->set_node(0) = mesh->node_ptr(3);
354  elem1->set_node(1) = mesh->node_ptr(2);
355  elem1->set_node(2) = mesh->node_ptr(4);
356  elem1->set_node(3) = mesh->node_ptr(5);
357 
358  mesh->prepare_for_use();
359 
360  libMesh::Point origin(0.0,1.0);
361  libMesh::Real theta = 0.0;
362 
363  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
364  rayfire->init(*mesh);
365 
366  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(elem0->id()) );
367  CPPUNIT_ASSERT( !rayfire->map_to_rayfire_elem(elem1->id()) );
368 
369  elem0->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
370 
371  libMesh::MeshRefinement mr(*mesh);
372  mr.refine_elements();
373 
374  rayfire->reinit(*mesh);
375 
376  CPPUNIT_ASSERT( !rayfire->map_to_rayfire_elem(elem1->id()) );
377 
378  CPPUNIT_ASSERT( !rayfire->map_to_rayfire_elem(elem0->child_ptr(0)->id()) );
379  CPPUNIT_ASSERT( !rayfire->map_to_rayfire_elem(elem0->child_ptr(1)->id()) );
380  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(elem0->child_ptr(2)->id()) );
381  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(elem0->child_ptr(3)->id()) );
382  }
RayfireMesh.
Definition: rayfire_mesh.h:65
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
void GRINSTesting::RayfireTestAMR::single_elems ( )
inline

Refine a single element.

Definition at line 82 of file rayfireAMR_test.C.

References build_quad4_elem(), build_quad9_elem(), and test_single_elem().

83  {
84  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = build_quad4_elem();
85  test_single_elem(mesh);
86 
87  mesh = build_quad9_elem();
88  test_single_elem(mesh);
89  }
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad9_elem()
Build a single square QUAD9.
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad4_elem()
Build a single square QUAD4.
void test_single_elem(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)
Runs the test on single square QUADs of unit length and width.
void GRINSTesting::RayfireTestAMR::start_with_refined_mesh ( )
inline

Mesh given to init() is already refined.

Definition at line 285 of file rayfireAMR_test.C.

References build_quad4_elem(), and calc_theta().

286  {
287  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = build_quad4_elem();
288 
289  // uniform refinement
290  libMesh::MeshRefinement mr(*mesh);
291  mr.uniformly_refine();
292 
293  // now init the rayfire
294  libMesh::Point origin(0.0,0.1);
295  libMesh::Point end_point(1.0,0.1);
296  libMesh::Real theta = calc_theta(origin,end_point);
297 
298  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
299  rayfire->init(*mesh);
300 
301  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->id()) );
302  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->id()) );
303 
304  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(2)->id())) );
305  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(3)->id())) );
306 
307  // refine again
308  mr.uniformly_refine();
309  rayfire->reinit(*mesh);
310 
311  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->child_ptr(0)->id()) );
312  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->child_ptr(1)->id()) );
313  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(0)->id()) );
314  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(1)->id()) );
315 
316  // uniformly coarsen twice to get back to a single elem
317  mr.uniformly_coarsen();
318  rayfire->reinit(*mesh);
319  mr.uniformly_coarsen();
320  rayfire->reinit(*mesh);
321 
322  // ensure the original elem is active
323  CPPUNIT_ASSERT( mesh->elem_ptr(0)->active() );
324 
325  // the original elem should be in the rayfire
326  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(0) );
327 
328  // and no other elem
329  for (unsigned int e=1; e<mesh->n_elem(); e++)
330  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(e)) );
331  }
RayfireMesh.
Definition: rayfire_mesh.h:65
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad4_elem()
Build a single square QUAD4.
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::test_coarsen ( GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh)
inlineprivate

Test coarsening specific elements on a large mesh.

Definition at line 778 of file rayfireAMR_test.C.

References calc_theta().

Referenced by coarsen_elements().

779  {
780  libMesh::Point origin(0.0,6.5);
781  libMesh::Point end_point(10.0,0.25);
782  libMesh::Real theta = calc_theta(origin,end_point);
783 
784  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
785  rayfire->init(*mesh);
786 
787  // unifromly refine the elements
788  libMesh::MeshRefinement mr(*mesh);
789  mr.uniformly_refine();
790  rayfire->reinit(*mesh);
791 
792  // coarsen specific elements along the rayfire
793  for(unsigned int c=0; c<4; c++)
794  {
795  mesh->elem_ptr(60)->child_ptr(c)->set_refinement_flag(libMesh::Elem::RefinementState::COARSEN);
796  mesh->elem_ptr(25)->child_ptr(c)->set_refinement_flag(libMesh::Elem::RefinementState::COARSEN);
797  mesh->elem_ptr(26)->child_ptr(c)->set_refinement_flag(libMesh::Elem::RefinementState::COARSEN);
798  mesh->elem_ptr(9)->child_ptr(c)->set_refinement_flag(libMesh::Elem::RefinementState::COARSEN);
799  }
800 
801  mr.coarsen_elements();
802  rayfire->reinit(*mesh);
803 
804  // check that the coarsened elems are in the rayfire
805  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(60) );
806  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(25) );
807  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(26) );
808  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(9) );
809 
810  // and that their children are not
811  for(unsigned int c=0; c<4; c++)
812  {
813  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(60)->child_ptr(c)->id())) );
814  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(25)->child_ptr(c)->id())) );
815  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(26)->child_ptr(c)->id())) );
816  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem(mesh->elem_ptr(9)->child_ptr(c)->id())) );
817  }
818  }
RayfireMesh.
Definition: rayfire_mesh.h:65
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::test_deformed_elem ( GRINS::SharedPtr< libMesh::UnstructuredMesh > &  mesh,
libMesh::Point &  origin,
libMesh::Real  theta,
std::vector< unsigned int > &  children_in_rayfire,
std::vector< unsigned int > &  children_not_in_rayfire 
)
inlineprivate

Definition at line 820 of file rayfireAMR_test.C.

Referenced by refine_deformed_elem(), and refine_deformed_elem_near_tolerance().

824  {
825  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
826  rayfire->init(*mesh);
827 
828  libMesh::Elem* elem = mesh->elem_ptr(0);
829  CPPUNIT_ASSERT(elem);
830 
831  elem->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
832 
833  libMesh::MeshRefinement mr(*mesh);
834  mr.refine_elements();
835 
836  rayfire->reinit(*mesh);
837 
838  for (unsigned int c=0; c<children_in_rayfire.size(); c++)
839  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(children_in_rayfire[c])->id()) );
840 
841  for (unsigned int c=0; c<children_not_in_rayfire.size(); c++)
842  CPPUNIT_ASSERT( !rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(children_not_in_rayfire[c])->id()) );
843 
844  }
RayfireMesh.
Definition: rayfire_mesh.h:65
void GRINSTesting::RayfireTestAMR::test_large_mesh ( GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh)
inlineprivate

Refine specific elements on a large mesh.

Definition at line 655 of file rayfireAMR_test.C.

References calc_theta().

Referenced by large_2D_mesh().

656  {
657  libMesh::Point origin(0.0,6.5);
658  libMesh::Point end_point(10.0,0.25);
659  libMesh::Real theta = calc_theta(origin,end_point);
660 
661  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
662  rayfire->init(*mesh);
663 
664  // manually refine specific elements
665  // map index 0: main_elem id to refine
666  // map index 1: children that should be in the rayfire post-refinement
667  std::map<unsigned int,std::vector<unsigned int> > refine_elems;
668  refine_elems[60] = std::vector<unsigned int>();
669  refine_elems[60].push_back(0);
670  refine_elems[60].push_back(1);
671 
672  refine_elems[52] = std::vector<unsigned int>();
673  refine_elems[52].push_back(0);
674 
675  refine_elems[34] = std::vector<unsigned int>();
676  refine_elems[34].push_back(1);
677  refine_elems[34].push_back(2);
678  refine_elems[34].push_back(3);
679 
680  refine_elems[25] = std::vector<unsigned int>();
681  refine_elems[25].push_back(3);
682 
683  refine_elems[26] = std::vector<unsigned int>();
684  refine_elems[26].push_back(0);
685  refine_elems[26].push_back(1);
686  refine_elems[26].push_back(2);
687 
688  refine_elems[17] = std::vector<unsigned int>();
689  refine_elems[17].push_back(2);
690  refine_elems[17].push_back(3);
691 
692  refine_elems[9] = std::vector<unsigned int>();
693  refine_elems[9].push_back(1);
694  refine_elems[9].push_back(2);
695  refine_elems[9].push_back(3);
696 
697  // check to make sure those elements are along the rayfire
698  // and then set their refinement flags
699  std::map<unsigned int,std::vector<unsigned int> >::iterator it = refine_elems.begin();
700  for(; it != refine_elems.end(); it++)
701  {
702  libMesh::Elem* elem = mesh->elem_ptr( it->first );
703  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(elem->id()) );
704  elem->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
705  }
706 
707  // refine the elements
708  libMesh::MeshRefinement mr(*mesh);
709  mr.refine_elements();
710 
711  // reinitialize the rayfire
712  rayfire->reinit(*mesh);
713 
714  // check the refined elements and their children
715  it = refine_elems.begin();
716  for(; it != refine_elems.end(); it++)
717  {
718  libMesh::Elem* elem = mesh->elem_ptr( it->first );
719 
720  // make sure it was refined
721  CPPUNIT_ASSERT_EQUAL( elem->refinement_flag(), libMesh::Elem::RefinementState::INACTIVE );
722 
723  // make sure it was deleted from the rayfire
724  CPPUNIT_ASSERT( !( rayfire->map_to_rayfire_elem(elem->id()) ) );
725 
726  // check that the computed children are in the rayfire
727  // and that the rest are not
728  std::vector<unsigned int> children = it->second;
729  unsigned int index = 0;
730  for(unsigned int c=0; c<elem->n_children(); c++)
731  {
732  if (index<children.size())
733  {
734  if (c==children[index])
735  {
736  index++;
737  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem( elem->child_ptr(c)->id() ) );
738  }
739  }
740  else
741  CPPUNIT_ASSERT( !(rayfire->map_to_rayfire_elem( elem->child_ptr(c)->id() )) );
742  }
743  }
744  }
RayfireMesh.
Definition: rayfire_mesh.h:65
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::test_multiple_refinements ( GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh)
inlineprivate

Refine the mesh 3 times.

Definition at line 747 of file rayfireAMR_test.C.

References calc_theta().

Referenced by multiple_refinements().

748  {
749  libMesh::Point origin(0.0,0.0);
750  libMesh::Point end_point(1.0,0.25);
751  libMesh::Real theta = calc_theta(origin,end_point);
752 
753  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
754  rayfire->init(*mesh);
755 
756  libMesh::MeshRefinement mr(*mesh);
757 
758  // do 3 successive uniform refinements
759  for (unsigned int i=0; i<3; i++)
760  {
761  mr.uniformly_refine();
762  rayfire->reinit(*mesh);
763  }
764 
765  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->child_ptr(0)->child_ptr(0)->id()) );
766  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->child_ptr(0)->child_ptr(1)->id()) );
767  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->child_ptr(1)->child_ptr(0)->id()) );
768  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(0)->child_ptr(1)->child_ptr(1)->id()) );
769 
770  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(0)->child_ptr(2)->id()) );
771  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(0)->child_ptr(3)->id()) );
772  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(1)->child_ptr(2)->id()) );
773  CPPUNIT_ASSERT( rayfire->map_to_rayfire_elem(mesh->elem_ptr(0)->child_ptr(1)->child_ptr(1)->child_ptr(3)->id()) );
774 
775  }
RayfireMesh.
Definition: rayfire_mesh.h:65
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::test_near_vertex ( GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh)
inlineprivate

Definition at line 621 of file rayfireAMR_test.C.

References calc_theta().

Referenced by near_vertex_postrefinement().

622  {
623  libMesh::Point origin(0.4999,0.0);
624  libMesh::Point end_point(1.0,1.0);
625  libMesh::Real theta = calc_theta(origin,end_point);
626 
627  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
628  rayfire->init(*mesh);
629 
630  libMesh::Elem* elem = mesh->elem_ptr(0);
631  CPPUNIT_ASSERT(elem);
632 
633  elem->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
634 
635  libMesh::MeshRefinement mr(*mesh);
636  mr.refine_elements();
637 
638  rayfire->reinit(*mesh);
639 
640  const libMesh::Elem* rayfire_elem0 = rayfire->map_to_rayfire_elem( elem->child_ptr(0)->id() );
641  CPPUNIT_ASSERT(rayfire_elem0);
642 
643  const libMesh::Elem* rayfire_elem1 = rayfire->map_to_rayfire_elem( elem->child_ptr(1)->id() );
644  CPPUNIT_ASSERT(rayfire_elem1);
645 
646  const libMesh::Elem* rayfire_elem2 = rayfire->map_to_rayfire_elem( elem->child_ptr(3)->id() );
647  CPPUNIT_ASSERT(rayfire_elem2);
648 
649  // not in rayfire
650  const libMesh::Elem* non_rayfire_elem = rayfire->map_to_rayfire_elem( elem->child_ptr(2)->id() );
651  CPPUNIT_ASSERT(!non_rayfire_elem);
652  }
RayfireMesh.
Definition: rayfire_mesh.h:65
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::test_single_elem ( GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh)
inlineprivate

Runs the test on single square QUADs of unit length and width.

Definition at line 557 of file rayfireAMR_test.C.

References calc_theta().

Referenced by single_elems().

558  {
559  CPPUNIT_ASSERT_EQUAL( mesh->n_elem(), (libMesh::dof_id_type)1 );
560 
561  libMesh::Point origin(0.0,0.1);
562  libMesh::Point end_point(1.0,0.2);
563  libMesh::Real theta = calc_theta(origin,end_point);
564 
565  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
566  rayfire->init(*mesh);
567 
568  libMesh::Elem* elem = mesh->elem_ptr(0);
569  CPPUNIT_ASSERT(elem);
570 
571  elem->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
572 
573  libMesh::MeshRefinement mr(*mesh);
574  mr.refine_elements();
575 
576  rayfire->reinit(*mesh);
577 
578  const libMesh::Elem* rayfire_elem0 = rayfire->map_to_rayfire_elem( elem->child_ptr(0)->id() );
579  CPPUNIT_ASSERT(rayfire_elem0);
580 
581  const libMesh::Elem* rayfire_elem1 = rayfire->map_to_rayfire_elem( elem->child_ptr(1)->id() );
582  CPPUNIT_ASSERT(rayfire_elem1);
583 
584  CPPUNIT_ASSERT( (rayfire_elem0->node_ptr(0))->absolute_fuzzy_equals(origin) );
585  CPPUNIT_ASSERT( (rayfire_elem0->node_ptr(1))->absolute_fuzzy_equals(libMesh::Point(0.5,0.15)) );
586  CPPUNIT_ASSERT( (rayfire_elem1->node_ptr(0))->absolute_fuzzy_equals(libMesh::Point(0.5,0.15)) );
587  CPPUNIT_ASSERT( (rayfire_elem1->node_ptr(1))->absolute_fuzzy_equals(end_point) );
588  }
RayfireMesh.
Definition: rayfire_mesh.h:65
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::test_through_vertex ( GRINS::SharedPtr< libMesh::UnstructuredMesh >  mesh)
inlineprivate

Definition at line 590 of file rayfireAMR_test.C.

References calc_theta().

Referenced by through_vertex_postrefinment().

591  {
592  libMesh::Point origin(0.0,0.0);
593  libMesh::Point end_point(1.0,1.0);
594  libMesh::Real theta = calc_theta(origin,end_point);
595 
596  GRINS::SharedPtr<GRINS::RayfireMesh> rayfire = new GRINS::RayfireMesh(origin,theta);
597  rayfire->init(*mesh);
598 
599  libMesh::Elem* elem = mesh->elem_ptr(0);
600  CPPUNIT_ASSERT(elem);
601 
602  elem->set_refinement_flag(libMesh::Elem::RefinementState::REFINE);
603 
604  libMesh::MeshRefinement mr(*mesh);
605  mr.refine_elements();
606 
607  rayfire->reinit(*mesh);
608 
609  const libMesh::Elem* rayfire_elem0 = rayfire->map_to_rayfire_elem( elem->child_ptr(0)->id() );
610  CPPUNIT_ASSERT(rayfire_elem0);
611 
612  const libMesh::Elem* rayfire_elem1 = rayfire->map_to_rayfire_elem( elem->child_ptr(3)->id() );
613  CPPUNIT_ASSERT(rayfire_elem1);
614 
615  CPPUNIT_ASSERT( (rayfire_elem0->node_ptr(0))->absolute_fuzzy_equals(origin) );
616  CPPUNIT_ASSERT( (rayfire_elem0->node_ptr(1))->absolute_fuzzy_equals(libMesh::Point(0.5,0.5)) );
617  CPPUNIT_ASSERT( (rayfire_elem1->node_ptr(0))->absolute_fuzzy_equals(libMesh::Point(0.5,0.5)) );
618  CPPUNIT_ASSERT( (rayfire_elem1->node_ptr(1))->absolute_fuzzy_equals(end_point) );
619  }
RayfireMesh.
Definition: rayfire_mesh.h:65
libMesh::Real calc_theta(libMesh::Point &start, libMesh::Point end)
void GRINSTesting::RayfireTestAMR::through_vertex_postrefinment ( )
inline

After refinement, the rayfire will travel through a vertex.

Definition at line 92 of file rayfireAMR_test.C.

References build_quad4_elem(), build_quad9_elem(), and test_through_vertex().

93  {
94  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = build_quad4_elem();
95  test_through_vertex(mesh);
96 
97  mesh = build_quad9_elem();
98  test_through_vertex(mesh);
99  }
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad9_elem()
Build a single square QUAD9.
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_quad4_elem()
Build a single square QUAD4.
void test_through_vertex(GRINS::SharedPtr< libMesh::UnstructuredMesh > mesh)

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