MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test_point_function

Function test_point_function

tests/mesh/test-regular-grid-function.cpp:118–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118void test_point_function()
119{
120 auto grid = geode::RegularGrid3D::create();
121 auto builder = geode::RegularGridBuilder3D::create( *grid );
122 builder->initialize_grid(
123 geode::Point3D{ { 1.5, 0, 1 } }, { 5, 10, 15 }, { 1, 2, 3 } );
124 const auto function_name = "point_function";
125 auto point_function = geode::GridPointFunction< 3, 3 >::create(
126 *grid, function_name, geode::Point3D{ { 26, 2, -10 } } );
127 point_function.set_value( { 1, 2, 3 }, geode::Point3D{ { 22, -3, -20 } } );
128 for( const auto i : geode::LRange{ 6 } )
129 {
130 for( const auto j : geode::LRange{ 11 } )
131 {
132 for( const auto k : geode::LRange{ 16 } )
133 {
134 if( i == 1 && j == 2 && k == 3 )
135 {
136 geode::OpenGeodeMeshException::test(
137 ( point_function.value(
138 geode::Grid3D::VertexIndices{ { i, j, k } } )
139 == geode::Point3D{ { 22, -3, -20 } } ),
140 "Point function value is wrong." );
141 }
142 else
143 {
144 geode::OpenGeodeMeshException::test(
145 ( point_function.value(
146 geode::Grid3D::VertexIndices{ { i, j, k } } )
147 == geode::Point3D{ { 26, 2, -10 } } ),
148 "Point function value is wrong." );
149 }
150 }
151 }
152 }
153 point_function.set_value( 217, geode::Point3D{ { 22, -3, -20 } } );
154 geode::OpenGeodeMeshException::test(
155 ( point_function.value( 217 ) == geode::Point3D{ { 22, -3, -20 } } ),
156 "Point function value is wrong." );
157 point_function.set_value( { 1, 2, 4 }, geode::Point3D{ { 22, -3, -20 } } );
158 point_function.set_value( { 1, 3, 4 }, geode::Point3D{ { 22, -3, -20 } } );
159 point_function.set_value( { 2, 2, 3 }, geode::Point3D{ { 22, -3, -20 } } );
160 point_function.set_value( { 2, 3, 3 }, geode::Point3D{ { 22, -3, -20 } } );
161 point_function.set_value( { 2, 2, 4 }, geode::Point3D{ { 22, -3, -20 } } );
162 point_function.set_value( { 2, 3, 4 }, geode::Point3D{ { 22, -3, -20 } } );
163 geode::Point3D point{ { 2.6, 4.1, 11.2 } };
164 auto cell_indices = grid->cells( point );
165 geode::OpenGeodeMeshException::test(
166 point_function.value( point, cell_indices[0] )
167 .inexact_equal( geode::Point3D{ { 22, -3, -20 } } ),
168 "Point function value 1 is wrong." );
169 point = geode::Point3D{ { 1.5, 0, 1 } };
170 cell_indices = grid->cells( point );
171 geode::OpenGeodeMeshException::test(
172 point_function.value( point, cell_indices[0] )
173 .inexact_equal( geode::Point3D{ { 26, 2, -10 } } ),
174 "Point function value 2 is wrong." );
175 point = geode::Point3D{ { 3, 4, 10 } };

Callers 1

testFunction · 0.70

Calls 6

testFunction · 0.70
initialize_gridMethod · 0.45
set_valueMethod · 0.45
valueMethod · 0.45
cellsMethod · 0.45
inexact_equalMethod · 0.45

Tested by

no test coverage detected