Commit affa1907 authored by Marcus Mohr's avatar Marcus Mohr
Browse files

Adds test for a full P2Function to FunctionIteratorTest.

Test currently fails because we get DoFs that claim to be neither
on an edge nor at a vertex.
parent d44ff5ea
Pipeline #26766 failed with stages
in 16 minutes and 50 seconds
......@@ -17,74 +17,87 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hyteg/FunctionIterator.hpp"
#include "core/DataTypes.h"
#include "core/Environment.h"
#include "core/debug/CheckFunctions.h"
#include "core/DataTypes.h"
#include "hyteg/FunctionIterator.hpp"
#include "hyteg/primitivestorage/PrimitiveStorage.hpp"
#include "hyteg/p2functionspace/P2Function.hpp"
#include "hyteg/primitivestorage/PrimitiveStorage.hpp"
using walberla::uint_t;
namespace hyteg {
static void testFunctionIterator( const std::string & meshFileName, const uint_t & level )
static void testFunctionIterator( const std::string& meshFileName, const uint_t& level )
{
auto storage = PrimitiveStorage::createFromGmshFile( meshFileName );
P1Function < int > nVertex( "nVertex", storage, level, level );
EdgeDoFFunction< int > nEdge ( "nEdge", storage, level, level );
nVertex.enumerate( level );
nEdge.enumerate( level );
auto storageInfo = storage->getGlobalInfo();
WALBERLA_LOG_INFO_ON_ROOT( storageInfo );
std::set< int > testEnumerateSet;
uint_t numGlobalDoFs;
uint_t numLocalDoFs;
WALBERLA_LOG_INFO_ON_ROOT( "--- Testing VertexDoFSpace ---" );
WALBERLA_MPI_BARRIER();
numGlobalDoFs = numberOfGlobalDoFs< P1FunctionTag >( *storage, level );
numLocalDoFs = numberOfLocalDoFs< P1FunctionTag >( *storage, level );
WALBERLA_LOG_INFO_ON_ROOT( "global dofs: " << numGlobalDoFs );
WALBERLA_LOG_INFO( "local dofs: " << numLocalDoFs );
for ( const auto & dof : FunctionIterator< P1Function< int > >( nVertex, level ) )
{
WALBERLA_CHECK( dof.isVertexDoF() )
WALBERLA_LOG_INFO( dof );
WALBERLA_CHECK_EQUAL( testEnumerateSet.count( dof.value() ), 0 );
testEnumerateSet.insert( dof.value() );
}
WALBERLA_CHECK_EQUAL( testEnumerateSet.size(), numLocalDoFs );
testEnumerateSet.clear();
WALBERLA_MPI_BARRIER();
WALBERLA_LOG_INFO_ON_ROOT( "--- Testing EdgeDoFSpace ---" );
WALBERLA_MPI_BARRIER();
numGlobalDoFs = numberOfGlobalDoFs< EdgeDoFFunctionTag >( *storage, level );
numLocalDoFs = numberOfLocalDoFs< EdgeDoFFunctionTag >( *storage, level );
WALBERLA_LOG_INFO_ON_ROOT( "global dofs: " << numGlobalDoFs );
WALBERLA_LOG_INFO( "local dofs: " << numLocalDoFs );
for ( const auto & dof : FunctionIterator< EdgeDoFFunction< int > >( nEdge, level ) )
{
WALBERLA_CHECK( dof.isEdgeDoF() )
WALBERLA_LOG_INFO( dof );
WALBERLA_CHECK_EQUAL( testEnumerateSet.count( dof.value() ), 0 );
testEnumerateSet.insert( dof.value() );
}
WALBERLA_CHECK_EQUAL( testEnumerateSet.size(), numLocalDoFs );
auto storage = PrimitiveStorage::createFromGmshFile( meshFileName );
P1Function< int > nVertex( "nVertex", storage, level, level );
EdgeDoFFunction< int > nEdge( "nEdge", storage, level, level );
nVertex.enumerate( level );
nEdge.enumerate( level );
auto storageInfo = storage->getGlobalInfo();
WALBERLA_LOG_INFO_ON_ROOT( storageInfo );
std::set< int > testEnumerateSet;
uint_t numGlobalDoFs;
uint_t numLocalDoFs;
WALBERLA_LOG_INFO_ON_ROOT( "--- Testing VertexDoFSpace ---" );
WALBERLA_MPI_BARRIER();
numGlobalDoFs = numberOfGlobalDoFs< P1FunctionTag >( *storage, level );
numLocalDoFs = numberOfLocalDoFs< P1FunctionTag >( *storage, level );
WALBERLA_LOG_INFO_ON_ROOT( "global dofs: " << numGlobalDoFs );
WALBERLA_LOG_INFO( "local dofs: " << numLocalDoFs );
for ( const auto& dof : FunctionIterator< P1Function< int > >( nVertex, level ) )
{
WALBERLA_CHECK( dof.isVertexDoF() )
WALBERLA_LOG_INFO( dof );
WALBERLA_CHECK_EQUAL( testEnumerateSet.count( dof.value() ), 0 );
testEnumerateSet.insert( dof.value() );
}
WALBERLA_CHECK_EQUAL( testEnumerateSet.size(), numLocalDoFs );
testEnumerateSet.clear();
WALBERLA_MPI_BARRIER();
WALBERLA_LOG_INFO_ON_ROOT( "--- Testing EdgeDoFSpace ---" );
WALBERLA_MPI_BARRIER();
numGlobalDoFs = numberOfGlobalDoFs< EdgeDoFFunctionTag >( *storage, level );
numLocalDoFs = numberOfLocalDoFs< EdgeDoFFunctionTag >( *storage, level );
WALBERLA_LOG_INFO_ON_ROOT( "global dofs: " << numGlobalDoFs );
WALBERLA_LOG_INFO( "local dofs: " << numLocalDoFs );
for ( const auto& dof : FunctionIterator< EdgeDoFFunction< int > >( nEdge, level ) )
{
WALBERLA_CHECK( dof.isEdgeDoF() )
WALBERLA_LOG_INFO( dof );
WALBERLA_CHECK_EQUAL( testEnumerateSet.count( dof.value() ), 0 );
testEnumerateSet.insert( dof.value() );
}
WALBERLA_CHECK_EQUAL( testEnumerateSet.size(), numLocalDoFs );
WALBERLA_MPI_BARRIER();
WALBERLA_LOG_INFO_ON_ROOT( "--- Testing P2 Function ---" );
WALBERLA_MPI_BARRIER();
P2Function< real_t > p2Func( "P2 test func", storage, level, level );
for ( auto val : FunctionIterator< P2Function< real_t > >( p2Func, level ) )
{
if ( !val.isEdgeDoF() && !val.isVertexDoF() )
{
WALBERLA_ABORT( "P2 DoF must be either on micro edge or micro vertex!" );
}
}
}
} // namespace hyteg
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment