-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7570ae
commit 3f7ea8e
Showing
8 changed files
with
3,377 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// | ||
// Copyright (C) University College London, 2007-2012, all rights reserved. | ||
// | ||
// This file is part of HemeLB and is CONFIDENTIAL. You may not work | ||
// with, install, use, duplicate, modify, redistribute or share this | ||
// file, or any part thereof, other than as allowed by any agreement | ||
// specifically made by you with University College London. | ||
// | ||
|
||
#ifndef HEMELB_UNITTESTS_TIMM_MESH_H | ||
#define HEMELB_UNITTESTS_TIMM_MESH_H | ||
|
||
#include <sstream> | ||
#include <cppunit/TestFixture.h> | ||
#include "resources/Resource.h" | ||
#include "redblood/Mesh.h" | ||
#include "unittests/redblood/Fixtures.h" | ||
|
||
namespace hemelb | ||
{ | ||
namespace unittests | ||
{ | ||
namespace redblood | ||
{ | ||
// Tests we can load .msh files output by Timm's code | ||
class LoadingTimmMeshTests : public BasisFixture | ||
{ | ||
CPPUNIT_TEST_SUITE (LoadingTimmMeshTests); | ||
CPPUNIT_TEST (testWrongIcoFile); | ||
CPPUNIT_TEST (testCorrectedIcoFile); | ||
CPPUNIT_TEST (testSimulationOutputFile); | ||
CPPUNIT_TEST_SUITE_END(); | ||
|
||
public: | ||
void setUp() | ||
{ | ||
} | ||
|
||
bool checkMeshOrientation(MeshData const &mesh) | ||
{ | ||
MeshData copy(mesh); | ||
orientFacets(copy); | ||
for (size_t i(0); i < mesh.facets.size(); ++i) | ||
{ | ||
if (mesh.facets[i] != copy.facets[i]) | ||
{ | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
std::shared_ptr<MeshData> readMeshFromFileNoFix(const std::string filename) | ||
{ | ||
auto fullPath = resources::Resource(filename).Path(); | ||
CPPUNIT_ASSERT(util::file_exists(fullPath.c_str())); | ||
|
||
std::ifstream file; | ||
file.open(fullPath); | ||
|
||
return readMesh(file, false); | ||
} | ||
|
||
void testWrongIcoFile() | ||
{ | ||
// This is one of Timm's original ico files and has a face with the wrong vertex orientation leading to an inward pointing normal | ||
// Loading it without fixing face orientation should lead to inconsistent orientation | ||
auto mesh = readMeshFromFileNoFix("rbc_ico_720.msh"); | ||
CPPUNIT_ASSERT(!checkMeshOrientation(*mesh)); | ||
} | ||
|
||
void testCorrectedIcoFile() | ||
{ | ||
// This is the same ico file with the face fixed | ||
// Loading it without fixing face orientation should be fine | ||
auto mesh = readMeshFromFileNoFix("rbc_ico_720_correct.msh"); | ||
CPPUNIT_ASSERT(checkMeshOrientation(*mesh)); | ||
} | ||
|
||
void testSimulationOutputFile() | ||
{ | ||
// This is a mesh taken from a simulation in Timm's code, which should have correct face orientation by definition | ||
auto mesh = readMeshFromFileNoFix("992Particles_rank3_26_t992.msh"); | ||
CPPUNIT_ASSERT(checkMeshOrientation(*mesh)); | ||
} | ||
}; | ||
|
||
CPPUNIT_TEST_SUITE_REGISTRATION (LoadingTimmMeshTests); | ||
} | ||
} | ||
} | ||
|
||
#endif // ONCE |
Oops, something went wrong.