Skip to content

Commit

Permalink
Add TET tests for rayfire
Browse files Browse the repository at this point in the history
  • Loading branch information
tradowsk committed Sep 5, 2018
1 parent 175cddf commit 855ad90
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 2 deletions.
50 changes: 50 additions & 0 deletions test/interface/rayfire_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "libmesh/face_quad9.h"
#include "libmesh/cell_hex8.h"
#include "libmesh/cell_hex27.h"
#include "libmesh/cell_tet4.h"
#include "libmesh/cell_tet10.h"

#include <tuple>

Expand Down Expand Up @@ -259,6 +261,54 @@ namespace GRINSTesting
return mesh;
}

//! Build a single TET4
std::shared_ptr<libMesh::UnstructuredMesh> build_tet4_elem()
{
std::shared_ptr<libMesh::UnstructuredMesh> mesh( new libMesh::SerialMesh(*TestCommWorld) );

mesh->set_mesh_dimension(3);

mesh->add_point( libMesh::Point(0.0,0.0,0.0),0 );
mesh->add_point( libMesh::Point(1.0,0.0,0.0),1 );
mesh->add_point( libMesh::Point(0.0,1.0,0.0),2 );
mesh->add_point( libMesh::Point(0.0,0.0,1.0),3 );

libMesh::Elem* elem = mesh->add_elem( new libMesh::Tet4 );
for (unsigned int n=0; n<4; n++)
elem->set_node(n) = mesh->node_ptr(n);

mesh->prepare_for_use();

return mesh;
}

//! Build a single TET10
std::shared_ptr<libMesh::UnstructuredMesh> build_tet10_elem()
{
std::shared_ptr<libMesh::UnstructuredMesh> mesh( new libMesh::SerialMesh(*TestCommWorld) );

mesh->set_mesh_dimension(3);

mesh->add_point( libMesh::Point(0.0,0.0,0.0),0 );
mesh->add_point( libMesh::Point(1.0,0.0,0.0),1 );
mesh->add_point( libMesh::Point(0.0,1.0,0.0),2 );
mesh->add_point( libMesh::Point(0.0,0.0,1.0),3 );
mesh->add_point( libMesh::Point(0.5,0.0,0.0),4 );
mesh->add_point( libMesh::Point(0.5,0.5,0.0),5 );
mesh->add_point( libMesh::Point(0.0,0.5,0.0),6 );
mesh->add_point( libMesh::Point(0.0,0.0,0.5),7 );
mesh->add_point( libMesh::Point(0.5,0.0,0.5),8 );
mesh->add_point( libMesh::Point(0.0,0.5,0.5),9 );

libMesh::Elem* elem = mesh->add_elem( new libMesh::Tet10 );
for (unsigned int n=0; n<10; n++)
elem->set_node(n) = mesh->node_ptr(n);

mesh->prepare_for_use();

return mesh;
}

void amr_single_elem( std::shared_ptr<libMesh::UnstructuredMesh> & mesh,
libMesh::Point & origin, libMesh::Point & end_point,
std::vector<unsigned int> & children_in_rayfire,
Expand Down
29 changes: 27 additions & 2 deletions test/unit/rayfireAMR_test_3d.C
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace GRINSTesting
CPPUNIT_TEST_SUITE( RayfireTestAMR3D );

CPPUNIT_TEST( single_hex );
CPPUNIT_TEST( single_tet );
CPPUNIT_TEST( through_vertex_postrefinment );
CPPUNIT_TEST( near_vertex_postrefinement );
CPPUNIT_TEST( refine_deformed_elem );
Expand All @@ -79,7 +80,6 @@ namespace GRINSTesting
void single_hex()
{
libMesh::Point origin(0.0,0.1,0.0);
libMesh::Point mid_point(0.5,0.15,0.5);
libMesh::Point end_point(1.0,0.2,1.0);

std::vector<unsigned int> children_in_rayfire;
Expand All @@ -103,11 +103,36 @@ namespace GRINSTesting
this->amr_single_elem(mesh,origin,end_point,children_in_rayfire,children_not_in_rayfire);
}

void single_tet()
{
libMesh::Point origin(0.0,0.1,0.0);
libMesh::Point end_point(0.25,0.25,0.5);

std::vector<unsigned int> children_in_rayfire;
children_in_rayfire.push_back(0);
children_in_rayfire.push_back(4);
children_in_rayfire.push_back(7);

std::vector<unsigned int> children_not_in_rayfire;
children_not_in_rayfire.push_back(1);
children_not_in_rayfire.push_back(2);
children_not_in_rayfire.push_back(3);
children_not_in_rayfire.push_back(5);
children_not_in_rayfire.push_back(6);

// TET4
std::shared_ptr<libMesh::UnstructuredMesh> mesh = this->build_tet4_elem();
this->amr_single_elem(mesh,origin,end_point,children_in_rayfire,children_not_in_rayfire);

// TET10
mesh = this->build_tet10_elem();
this->amr_single_elem(mesh,origin,end_point,children_in_rayfire,children_not_in_rayfire);
}

//! After refinement, the rayfire will travel through a vertex
void through_vertex_postrefinment()
{
libMesh::Point origin(0.0,0.0,0.0);
libMesh::Point mid_point(0.5,0.5,0.5);
libMesh::Point end_point(1.0,1.0,1.0);

std::vector<unsigned int> children_in_rayfire;
Expand Down
34 changes: 34 additions & 0 deletions test/unit/rayfire_test_3d.C
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@

#include "libmesh/cell_hex8.h"
#include "libmesh/cell_hex27.h"
#include "libmesh/cell_tet4.h"
#include "libmesh/cell_tet10.h"

// Ignore warnings from auto_ptr in CPPUNIT_TEST_SUITE_END()
#include <libmesh/ignore_warnings.h>
Expand All @@ -64,6 +66,8 @@ namespace GRINSTesting

CPPUNIT_TEST( hex8_all_sides );
CPPUNIT_TEST( hex27_all_sides );
CPPUNIT_TEST( tet4_all_sides );
CPPUNIT_TEST( tet10_all_sides );
CPPUNIT_TEST( hex_5elem_inline );
CPPUNIT_TEST( hex_27elem_3x3x3 );
CPPUNIT_TEST( fire_through_vertex );
Expand Down Expand Up @@ -108,6 +112,36 @@ namespace GRINSTesting
this->run_test_on_all_point_combinations(pts,mesh);
}

void tet4_all_sides()
{
// vector of intersection points
std::vector<libMesh::Point> pts(4);
pts[0] = libMesh::Point(0.11,0.17,0.0);
pts[1] = libMesh::Point(0.55,0.0,0.21);
pts[2] = libMesh::Point(0.0,0.83,0.04);
pts[3] = libMesh::Point(0.25,0.25,0.5);

// create the mesh (single TET4 element)
std::shared_ptr<libMesh::UnstructuredMesh> mesh = this->build_tet4_elem();

this->run_test_on_all_point_combinations(pts,mesh);
}

void tet10_all_sides()
{
// vector of intersection points
std::vector<libMesh::Point> pts(4);
pts[0] = libMesh::Point(0.11,0.17,0.0);
pts[1] = libMesh::Point(0.55,0.0,0.21);
pts[2] = libMesh::Point(0.0,0.83,0.04);
pts[3] = libMesh::Point(0.25,0.25,0.5);

// create the mesh (single TET10 element)
std::shared_ptr<libMesh::UnstructuredMesh> mesh = this->build_tet10_elem();

this->run_test_on_all_point_combinations(pts,mesh);
}

void hex_5elem_inline()
{
libMesh::Point origin = libMesh::Point(0,0.5,0.5);
Expand Down

0 comments on commit 855ad90

Please sign in to comment.