From 11abcd6b7baef31db8d0bee0a7b42366d2e9a410 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Fri, 9 Nov 2018 09:56:02 +0100 Subject: [PATCH] [PL/ST] Move checks to createSourceTerm(). --- ProcessLib/SourceTerms/CreateSourceTerm.cpp | 29 +++++++++++++++++++ ProcessLib/SourceTerms/NodalSourceTerm.cpp | 7 ----- .../Python/CreatePythonSourceTerm.cpp | 10 ------- .../SourceTerms/VolumetricSourceTerm.cpp | 18 ------------ 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/ProcessLib/SourceTerms/CreateSourceTerm.cpp b/ProcessLib/SourceTerms/CreateSourceTerm.cpp index 14d818ebec0..e111766ddc9 100644 --- a/ProcessLib/SourceTerms/CreateSourceTerm.cpp +++ b/ProcessLib/SourceTerms/CreateSourceTerm.cpp @@ -29,6 +29,35 @@ std::unique_ptr<SourceTerm> createSourceTerm( //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__type} auto const type = config.config.peekConfigParameter<std::string>("type"); + // check basic data consistency + if (variable_id >= + static_cast<int>(dof_table_bulk.getNumberOfVariables()) || + *config.component_id >= + dof_table_bulk.getNumberOfVariableComponents(variable_id)) + { + OGS_FATAL( + "Variable id or component id too high. Actual values: (%d, " + "%d), maximum values: (%d, %d).", + variable_id, *config.component_id, + dof_table_bulk.getNumberOfVariables(), + dof_table_bulk.getNumberOfVariableComponents(variable_id)); + } + + if (!source_term_mesh.getProperties() + .template existsPropertyVector<std::size_t>("bulk_node_ids")) + { + OGS_FATAL( + "The required bulk node ids map does not exist in the " + "source term mesh '%s'.", + source_term_mesh.getName().c_str()); + } + std::vector<MeshLib::Node*> const& source_term_nodes = + source_term_mesh.getNodes(); + DBUG( + "Found %d nodes for source term at mesh '%s' for the variable %d and " + "component %d", + source_term_nodes.size(), source_term_mesh.getName().c_str(), + variable_id, *config.component_id); MeshLib::MeshSubset source_term_mesh_subset(source_term_mesh, source_term_nodes); diff --git a/ProcessLib/SourceTerms/NodalSourceTerm.cpp b/ProcessLib/SourceTerms/NodalSourceTerm.cpp index bac7113a62e..5737be3aacd 100644 --- a/ProcessLib/SourceTerms/NodalSourceTerm.cpp +++ b/ProcessLib/SourceTerms/NodalSourceTerm.cpp @@ -28,13 +28,6 @@ NodalSourceTerm::NodalSourceTerm( _parameter(parameter) { DBUG("Create NodalSourceTerm."); - if (!_st_mesh.getProperties().template existsPropertyVector<std::size_t>( - "bulk_node_ids")) - { - OGS_FATAL( - "Required mesh property \"bulk_node_ids\" does not exists on the " - "source term mesh '%s'.", _st_mesh.getName().c_str()); - } } void NodalSourceTerm::integrate(const double t, GlobalVector const& /*x*/, diff --git a/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp b/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp index 924c1bd3f08..e8cb1635fbe 100644 --- a/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp +++ b/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp @@ -50,16 +50,6 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm( .cast<ProcessLib::SourceTerms::Python:: PythonSourceTermPythonSideInterface*>(); - if (variable_id >= static_cast<int>(dof_table.getNumberOfVariables()) || - component_id >= dof_table.getNumberOfVariableComponents(variable_id)) - { - OGS_FATAL( - "Variable id or component id too high. Actual values: (%d, %d), " - "maximum values: (%d, %d).", - variable_id, component_id, dof_table.getNumberOfVariables(), - dof_table.getNumberOfVariableComponents(variable_id)); - } - // In case of partitioned mesh the source_term could be empty, i.e. there is // no source_term condition. #ifdef USE_PETSC diff --git a/ProcessLib/SourceTerms/VolumetricSourceTerm.cpp b/ProcessLib/SourceTerms/VolumetricSourceTerm.cpp index 4643db51993..2656badbd18 100644 --- a/ProcessLib/SourceTerms/VolumetricSourceTerm.cpp +++ b/ProcessLib/SourceTerms/VolumetricSourceTerm.cpp @@ -22,24 +22,6 @@ VolumetricSourceTerm::VolumetricSourceTerm( : SourceTerm(std::move(source_term_dof_table)), _volumetric_source_term(volumetric_source_term) { - // check basic data consistency - if (variable_id >= - static_cast<int>(source_term_dof_table.getNumberOfVariables())) - { - OGS_FATAL( - "Variable id too high. Actual value: %d, maximum value: %d.", - variable_id, - source_term_dof_table.getNumberOfVariables()); - } - if (component_id >= - source_term_dof_table.getNumberOfVariableComponents(variable_id)) - { - OGS_FATAL( - "Component id too high. Actual value: %d, maximum value: %d.", - component_id, - source_term_dof_table.getNumberOfVariableComponents(variable_id)); - } - ProcessLib::createLocalAssemblers<VolumetricSourceTermLocalAssembler>( source_term_mesh.getDimension(), source_term_mesh.getElements(), *_source_term_dof_table, shapefunction_order, _local_assemblers, -- GitLab