-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenSemba | Make VTK Files have their Probe type in their names
- Loading branch information
1 parent
f820cdf
commit 81d2c70
Showing
16 changed files
with
219 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ out/ | |
.vs/ | ||
.vscode/ | ||
CMakeSettings.json | ||
/test/exporters/resultFiles/* |
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
add_subdirectory(core) | ||
add_subdirectory(parsers) | ||
add_subdirectory(parsers) | ||
add_subdirectory(exporters) |
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,46 @@ | ||
#include <gtest/gtest.h> | ||
#include <gmock/gmock.h> | ||
#include <gmock/gmock-matchers.h> | ||
|
||
#include "core/outputRequest/BulkCurrent.h" | ||
#include "core/outputRequest/Domain.h" | ||
#include "core/outputRequest/FarField.h" | ||
#include "core/outputRequest/OnLayer.h" | ||
#include "core/outputRequest/OnLine.h" | ||
#include "core/outputRequest/OnPoint.h" | ||
#include "core/outputRequest/OnSurface.h" | ||
#include "core/outputRequest/OutputRequest.h" | ||
|
||
using namespace semba; | ||
using namespace outputRequest; | ||
using namespace geometry; | ||
|
||
class OutputRequestTest : public ::testing::Test { | ||
|
||
void SetUp() {} | ||
|
||
void TearDown() {} | ||
|
||
}; | ||
|
||
TEST_F(OutputRequestTest, getOutputRequestTypeStrForName) { | ||
{ | ||
Domain domain; | ||
OutputRequest::Target target; | ||
OnLayer onLayer(OutputRequest::Type::magnetic, domain, "onLayer", target); | ||
OnLine onLine(OutputRequest::Type::magnetic, domain, "onLayer", target); | ||
OnSurface onSurface(OutputRequest::Type::magnetic, domain, "onLayer", target); | ||
|
||
FarField farField(domain, "FarField", target, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | ||
OnPoint onPoint(OutputRequest::Type::magnetic, domain, "onPoint", target); | ||
BulkCurrent bulk(domain, "bulkCurrent", target, math::Constants::CartesianAxis::x, 0); | ||
|
||
EXPECT_THAT(onLayer.getTypeStrForName(), ::testing::StrEq(std::string())); | ||
EXPECT_THAT(onLine.getTypeStrForName(), ::testing::StrEq(std::string())); | ||
EXPECT_THAT(onSurface.getTypeStrForName(), ::testing::StrEq(std::string())); | ||
|
||
EXPECT_THAT(farField.getTypeStrForName(), ::testing::StrEq(std::string("Far_Field"))); | ||
EXPECT_THAT(onPoint.getTypeStrForName(), ::testing::StrEq(std::string("On_Point"))); | ||
EXPECT_THAT(bulk.getTypeStrForName(), ::testing::StrEq(std::string("Bulk_Current"))); | ||
} | ||
} |
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,27 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
message(STATUS "Configuring build system for opensemba_exporters_tests.") | ||
|
||
find_package(GTest CONFIG REQUIRED) | ||
include_directories(${GTEST_INCLUDE_DIRS}) | ||
include(GoogleTest) | ||
|
||
add_executable(opensemba_exporters_tests | ||
"ExporterVTKTest.cpp" | ||
) | ||
|
||
target_link_libraries(opensemba_exporters_tests | ||
opensemba_exporters | ||
GTest::gtest | ||
GTest::gtest_main | ||
) | ||
|
||
|
||
gtest_add_tests( | ||
TARGET opensemba_exporters_tests | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
) | ||
gtest_discover_tests( | ||
opensemba_exporters_tests | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
) |
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,109 @@ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "core/geometry/element/Node.h" | ||
#include "core/geometry/element/Line2.h" | ||
#include "core/geometry/element/Hexahedron8.h" | ||
#include "core/outputRequest/BulkCurrent.h" | ||
#include "core/outputRequest/FarField.h" | ||
#include "core/outputRequest/OnLine.h" | ||
#include "core/outputRequest/OnPoint.h" | ||
#include "core/outputRequest/OutputRequest.h" | ||
#include "exporters/ExporterVTK.h" | ||
#include <nlohmann/json.hpp> | ||
|
||
using namespace semba::math::Constants; | ||
|
||
|
||
using namespace std; | ||
using namespace semba; | ||
using namespace outputRequest; | ||
using namespace geometry; | ||
|
||
class ExporterVTKTest : public ::testing::Test { | ||
|
||
void SetUp(){ | ||
|
||
} | ||
|
||
void TearDown() {} | ||
|
||
protected: | ||
ExporterVTKTest() { | ||
resultFilesFolder_ = "./test/exporters/resultFiles/"; | ||
} | ||
|
||
string resultFilesFolder_; | ||
string getCaseName(const string project) const { | ||
return resultFilesFolder_ + project; | ||
} | ||
|
||
string getVTKPath(const string project) { | ||
return getCaseName(project) + "/" + project + ".vtk"; | ||
} | ||
|
||
string getVtu(const string project, const string name, OutputRequest * request) { | ||
return getVTKPath(project) + "/" + "OutRq_" + request->getTypeStrForName() + "_" + name + ".vtu"; | ||
} | ||
|
||
void cleanFolders(const string path) const { | ||
if (filesystem::exists(path)) | ||
filesystem::remove_all(path); | ||
|
||
} | ||
|
||
void createFolder(const string path) const { | ||
filesystem::create_directory(path); | ||
} | ||
}; | ||
|
||
TEST_F(ExporterVTKTest, exportProbes) | ||
{ | ||
string projectName = "exportProbes"; | ||
string bulkProbeName = "probe1"; | ||
string pointProbeName = "probe2"; | ||
string farFieldName = "probe3"; | ||
string lineProbeName = "probe4"; | ||
|
||
cleanFolders(getCaseName(projectName)); | ||
createFolder(getCaseName(projectName)); | ||
|
||
UnstructuredProblemDescription unstructured; | ||
|
||
map<string, double> dictionary; | ||
dictionary["geometryScalingFactor"] = 0.0; | ||
unstructured.analysis = nlohmann::json(dictionary); | ||
|
||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(0, 0, 0))); | ||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(1, 0, 0))); | ||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(1, 1, 0))); | ||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(0, 1, 0))); | ||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(0, 0, 1))); | ||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(1, 0, 1))); | ||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(1, 1, 1))); | ||
unstructured.model.mesh.coords().addAndAssignId(make_unique<CoordR3>(math::CVecI3(0, 1, 1))); | ||
|
||
auto& bulkCoords = unstructured.model.mesh.coords().get(); | ||
vector<CoordR3*> pointCoord{ unstructured.model.mesh.coords().atId(CoordId(1)) }; | ||
auto& lineCoords{ unstructured.model.mesh.coords().atIds(vector<CoordId>{CoordId(2), CoordId(3)})}; | ||
|
||
NodR node; | ||
node.setV(0, pointCoord[0]); | ||
|
||
unstructured.model.mesh.elems().addAndAssignId(make_unique<HexR8>(ElemId(1), bulkCoords)); | ||
unstructured.model.mesh.elems().addAndAssignId(make_unique<NodR>(node)); | ||
unstructured.model.mesh.elems().addAndAssignId(make_unique<LinR2>(ElemId(3), lineCoords)); | ||
|
||
|
||
unstructured.outputRequests.addAndAssignId(make_unique<BulkCurrent>(Domain(), bulkProbeName, std::vector<ElemId>{ElemId(1)}, CartesianAxis::x, 5)); | ||
unstructured.outputRequests.addAndAssignId(make_unique<OnPoint>(OutputRequest::Type::current, Domain(), pointProbeName, std::vector<ElemId>{ElemId(2)})); | ||
unstructured.outputRequests.addAndAssignId(make_unique<FarField>(Domain(), farFieldName, std::vector<ElemId>{ElemId(2)}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); | ||
unstructured.outputRequests.addAndAssignId(make_unique<OnLine>(OutputRequest::Type::current, Domain(), lineProbeName, std::vector<ElemId>{ElemId(3)})); | ||
|
||
exporters::ExporterVTK exporter = exporters::ExporterVTK(unstructured, getCaseName(projectName) + "/" + projectName); | ||
|
||
EXPECT_TRUE(filesystem::exists(getVtu(projectName, bulkProbeName, unstructured.outputRequests.atId(Id(1))))); | ||
EXPECT_TRUE(filesystem::exists(getVtu(projectName, pointProbeName, unstructured.outputRequests.atId(Id(2))))); | ||
EXPECT_TRUE(filesystem::exists(getVtu(projectName, farFieldName, unstructured.outputRequests.atId(Id(3))))); | ||
EXPECT_TRUE(filesystem::exists(getVtu(projectName, lineProbeName, unstructured.outputRequests.atId(Id(4))))); | ||
} |
Empty file.