Skip to content
Snippets Groups Projects
Commit 767f6549 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Improve embedded data treatment

Now a mesh can be stored in a variable!
parent 2cf90149
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -198,6 +198,27 @@ ASTNodeAffectationExpressionBuilder::ASTNodeAffectationExpressionBuilder(ASTNode
}
};
auto set_affectation_processor_for_embedded_data = [&](const ASTNodeDataType& data_type) {
using OperatorT = std::decay_t<decltype(operator_v)>;
if constexpr (std::is_same_v<OperatorT, language::eq_op>) {
switch (data_type) {
case ASTNodeDataType::type_id_t: {
n.m_node_processor = std::make_unique<AffectationProcessor<OperatorT, EmbeddedData, EmbeddedData>>(n);
break;
}
// LCOV_EXCL_START
default: {
throw parse_error("unexpected error: undefined operand type for string affectation",
std::vector{n.children[1]->begin()});
}
// LCOV_EXCL_STOP
}
} else {
throw parse_error("invalid operator for '" + data_type.typeName() + "' affectation", std::vector{n.begin()});
}
};
auto set_affectation_processor_for_value = [&](const ASTNodeDataType& value_type) {
const ASTNodeDataType data_type = n.children[1]->m_data_type;
......@@ -244,6 +265,10 @@ ASTNodeAffectationExpressionBuilder::ASTNodeAffectationExpressionBuilder(ASTNode
set_affectation_processor_for_string_data(data_type);
break;
}
case ASTNodeDataType::type_id_t: {
set_affectation_processor_for_embedded_data(data_type);
break;
}
default: {
throw parse_error("unexpected error: undefined value type for affectation", std::vector{n.begin()});
}
......
......@@ -40,9 +40,12 @@ add_library(
# Additional dependencies
add_dependencies(PugsLanguage
PugsUtils)
PugsUtils
PugsMesh)
include_directories("${PUGS_SOURCE_DIR}/src/mesh"
"${PUGS_SOURCE_DIR}/src/algebra")
#add_dependencies(PugsMesh)
# ------------------- Installation --------------------
# temporary version workaround
......
......@@ -3,6 +3,9 @@
#include <BuiltinFunctionEmbedder.hpp>
#include <TypeDescriptor.hpp>
#include <GmshReader.hpp>
#include <Mesh.hpp>
class IMesh;
template <>
......@@ -15,10 +18,11 @@ MeshModule::MeshModule()
this->_addBuiltinFunction("readGmsh", std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr<IMesh>, std::string>>(
std::function<std::shared_ptr<IMesh>(std::string)>{
[](std::string s) -> std::shared_ptr<IMesh> {
std::cout << "evaluating 'readGmsh' using argument '" << rang::fg::yellow
<< s << rang::style::reset << "'\n";
return {};
}}));
[](std::string file_name) -> std::shared_ptr<IMesh> {
GmshReader gmsh_reader(file_name);
return gmsh_reader.mesh();
}}
));
}
......@@ -37,7 +37,9 @@ main(int argc, char* argv[])
std::regex gmsh_regex("(.*).msh");
if (not std::regex_match(filename, gmsh_regex)) {
SynchronizerManager::create();
parser(filename);
SynchronizerManager::destroy();
return 0;
}
......
......@@ -82,6 +82,7 @@ add_executable (mpi_unit_tests
target_link_libraries (unit_tests
PugsLanguage
PugsMesh
PugsUtils
kokkos
${PARMETIS_LIBRARIES}
......@@ -91,6 +92,7 @@ target_link_libraries (unit_tests
target_link_libraries (mpi_unit_tests
PugsUtils
PugsMesh
kokkos
${PARMETIS_LIBRARIES}
${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment