Skip to content
Snippets Groups Projects
Commit 109bb271 authored by Tom Fischer's avatar Tom Fischer
Browse files

[PL/ST] Use patch mesh instead entire mesh.

Use the specified patch mesh instead of the entire bulk mesh to define
the source term.
parent 9f6062ce
No related branches found
No related tags found
No related merge requests found
Showing
with 72 additions and 70 deletions
......@@ -222,7 +222,7 @@ ProcessVariable::createSourceTerms(
for (auto& config : _source_term_configs)
source_terms.emplace_back(createSourceTerm(
config, dof_table, _mesh, variable_id, integration_order,
config, dof_table, config.mesh, variable_id, integration_order,
_shapefunction_order, parameters));
return source_terms;
......
......@@ -20,8 +20,8 @@ namespace ProcessLib
{
std::unique_ptr<SourceTerm> createNodalSourceTerm(
BaseLib::ConfigTree const& config, MeshLib::Mesh const& st_mesh,
const NumLib::LocalToGlobalIndexMap& dof_table,
std::size_t const bulk_mesh_id, const int variable_id,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
std::size_t const source_term_mesh_id, const int variable_id,
const int component_id,
std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters)
{
......@@ -35,7 +35,8 @@ std::unique_ptr<SourceTerm> createNodalSourceTerm(
auto& param = findParameter<double>(param_name, parameters, 1);
return std::make_unique<NodalSourceTerm>(dof_table, bulk_mesh_id, st_mesh,
return std::make_unique<NodalSourceTerm>(std::move(dof_table),
source_term_mesh_id, st_mesh,
variable_id, component_id, param);
}
......
......@@ -34,8 +34,8 @@ namespace ProcessLib
{
std::unique_ptr<SourceTerm> createNodalSourceTerm(
BaseLib::ConfigTree const& config, MeshLib::Mesh const& st_mesh,
const NumLib::LocalToGlobalIndexMap& dof_table, std::size_t mesh_id,
const int variable_id, const int component_id,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
std::size_t mesh_id, const int variable_id, const int component_id,
std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters);
} // namespace ProcessLib
......@@ -22,35 +22,54 @@ namespace ProcessLib
std::unique_ptr<SourceTerm> createSourceTerm(
const SourceTermConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table_bulk,
const MeshLib::Mesh& mesh, const int variable_id,
const MeshLib::Mesh& source_term_mesh, const int variable_id,
const unsigned integration_order, const unsigned shapefunction_order,
std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters)
{
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__type}
auto const type = config.config.peekConfigParameter<std::string>("type");
MeshLib::MeshSubset source_term_mesh_subset(source_term_mesh,
source_term_nodes);
if (type == "Nodal")
{
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
dof_table_bulk.deriveBoundaryConstrainedMap(
variable_id, {*config.component_id},
std::move(source_term_mesh_subset)));
return ProcessLib::createNodalSourceTerm(
config.config, config.mesh, dof_table_bulk, mesh.getID(),
variable_id, *config.component_id, parameters);
config.config, config.mesh, std::move(dof_table_source_term),
source_term_mesh.getID(), variable_id, *config.component_id,
parameters);
}
if (type == "Volumetric")
{
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
dof_table_bulk.deriveBoundaryConstrainedMap(
variable_id, {*config.component_id},
std::move(source_term_mesh_subset)));
return ProcessLib::createVolumetricSourceTerm(
config.config, config.mesh, dof_table_bulk, parameters,
integration_order, shapefunction_order, variable_id,
config.config, config.mesh, std::move(dof_table_source_term),
parameters, integration_order, shapefunction_order, variable_id,
*config.component_id);
}
if (type == "Python")
{
#ifdef OGS_USE_PYTHON
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
dof_table_bulk.deriveBoundaryConstrainedMap(
std::move(source_term_mesh_subset)));
return ProcessLib::createPythonSourceTerm(
config.config, config.mesh, dof_table_bulk, mesh.getID(),
variable_id, *config.component_id, integration_order,
shapefunction_order, mesh.getDimension());
config.config, config.mesh, std::move(dof_table_source_term),
source_term_mesh.getID(), variable_id, *config.component_id,
integration_order, shapefunction_order,
source_term_mesh.getDimension());
#else
OGS_FATAL("OpenGeoSys has not been built with Python support.");
#endif
......
......@@ -21,7 +21,7 @@ namespace ProcessLib
std::unique_ptr<SourceTerm> createVolumetricSourceTerm(
BaseLib::ConfigTree const& config,
MeshLib::Mesh const& source_term_mesh,
NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order, unsigned const shapefunction_order,
int const variable_id, int const component_id)
......@@ -42,7 +42,7 @@ std::unique_ptr<SourceTerm> createVolumetricSourceTerm(
volumetric_source_term.name.c_str());
return std::make_unique<VolumetricSourceTerm>(
source_term_mesh, source_term_dof_table, integration_order,
source_term_mesh, std::move(source_term_dof_table), integration_order,
shapefunction_order, variable_id, component_id,
volumetric_source_term);
}
......
......@@ -35,7 +35,7 @@ class SourceTerm;
std::unique_ptr<SourceTerm> createVolumetricSourceTerm(
BaseLib::ConfigTree const& config,
MeshLib::Mesh const& source_term_mesh,
NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order, unsigned const shapefunction_order,
int const variable_id, int const component_id);
......
......@@ -14,14 +14,14 @@
namespace ProcessLib
{
NodalSourceTerm::NodalSourceTerm(
const NumLib::LocalToGlobalIndexMap& source_term_dof_table,
std::size_t const bulk_mesh_id,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
std::size_t const source_term_mesh_id,
MeshLib::Mesh const& st_mesh,
const int variable_id,
const int component_id,
Parameter<double> const& parameter)
: SourceTerm(source_term_dof_table),
_bulk_mesh_id(bulk_mesh_id),
: SourceTerm(std::move(source_term_dof_table)),
_source_term_mesh_id(source_term_mesh_id),
_st_mesh(st_mesh),
_variable_id(variable_id),
_component_id(component_id),
......@@ -42,15 +42,12 @@ void NodalSourceTerm::integrate(const double t, GlobalVector const& /*x*/,
{
DBUG("Assemble NodalSourceTerm.");
auto const& bulk_node_ids_map =
*_st_mesh.getProperties().template getPropertyVector<std::size_t>(
"bulk_node_ids");
for (MeshLib::Node const* const node : _st_mesh.getNodes())
{
auto const node_id = node->getID();
MeshLib::Location const l{_bulk_mesh_id, MeshLib::MeshItemType::Node,
bulk_node_ids_map[node_id]};
auto const index = _source_term_dof_table.getGlobalIndex(
MeshLib::Location const l{_source_term_mesh_id,
MeshLib::MeshItemType::Node, node_id};
auto const index = _source_term_dof_table->getGlobalIndex(
l, _variable_id, _component_id);
SpatialPosition pos;
......
......@@ -17,8 +17,8 @@ class NodalSourceTerm final : public SourceTerm
{
public:
explicit NodalSourceTerm(
const NumLib::LocalToGlobalIndexMap& source_term_dof_table,
std::size_t const bulk_mesh_id, MeshLib::Mesh const& st_mesh,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
std::size_t const source_term_mesh_id, MeshLib::Mesh const& st_mesh,
const int variable_id, const int component_id,
Parameter<double> const& parameter);
......@@ -26,7 +26,7 @@ public:
GlobalMatrix* jac) const override;
private:
std::size_t const _bulk_mesh_id;
std::size_t const _source_term_mesh_id;
MeshLib::Mesh const& _st_mesh;
int const _variable_id;
int const _component_id;
......
......@@ -21,7 +21,7 @@ namespace ProcessLib
{
std::unique_ptr<SourceTerm> createPythonSourceTerm(
BaseLib::ConfigTree const& config, MeshLib::Mesh const& source_term_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
std::size_t const bulk_mesh_id, int const variable_id,
int const component_id, unsigned const integration_order,
unsigned const shapefunction_order, unsigned const global_dim)
......@@ -75,12 +75,12 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm(
}
#endif // USE_PETSC
auto const global_component_id =
dof_table->getGlobalComponent(variable_id, component_id);
return std::make_unique<ProcessLib::SourceTerms::Python::PythonSourceTerm>(
dof_table,
std::move(dof_table),
ProcessLib::SourceTerms::Python::PythonSourceTermData{
source_term, dof_table, bulk_mesh_id,
dof_table.getGlobalComponent(variable_id, component_id),
source_term_mesh},
source_term, bulk_mesh_id, global_component_id, source_term_mesh},
integration_order, shapefunction_order, global_dim, flush_stdout);
}
......
......@@ -30,7 +30,7 @@ class SourceTerm;
std::unique_ptr<SourceTerm> createPythonSourceTerm(
BaseLib::ConfigTree const& config, MeshLib::Mesh const& source_term_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
std::size_t const bulk_mesh_id, int const variable_id,
int const component_id, unsigned const integration_order,
unsigned const shapefunction_order, unsigned const global_dim);
......
......@@ -58,28 +58,17 @@ namespace SourceTerms
namespace Python
{
PythonSourceTerm::PythonSourceTerm(
NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
PythonSourceTermData&& source_term_data, unsigned const integration_order,
unsigned const shapefunction_order, unsigned const global_dim,
bool const flush_stdout)
: SourceTerm(source_term_dof_table),
: SourceTerm(std::move(source_term_dof_table)),
_source_term_data(std::move(source_term_data)),
_flush_stdout(flush_stdout)
{
std::vector<MeshLib::Node*> const& source_term_nodes =
_source_term_data.source_term_mesh.getNodes();
MeshLib::MeshSubset source_term_mesh_subset(
_source_term_data.source_term_mesh, source_term_nodes);
// Create local DOF table from the source term mesh subset for the given
// variable and component id.
_dof_table_source_term =
_source_term_data.dof_table_bulk.deriveBoundaryConstrainedMap(
std::move(source_term_mesh_subset));
createLocalAssemblers<PythonSourceTermLocalAssembler>(
global_dim, _source_term_data.source_term_mesh.getElements(),
*_dof_table_source_term, shapefunction_order, _local_assemblers,
*_source_term_dof_table, shapefunction_order, _local_assemblers,
_source_term_data.source_term_mesh.isAxiallySymmetric(),
integration_order, _source_term_data);
}
......@@ -91,7 +80,7 @@ void PythonSourceTerm::integrate(const double t, const GlobalVector& x,
GlobalExecutor::executeMemberOnDereferenced(
&PythonSourceTermLocalAssemblerInterface::assemble, _local_assemblers,
*_dof_table_source_term, t, x, b, Jac);
*_source_term_dof_table, t, x, b, Jac);
}
} // namespace Python
......
......@@ -30,9 +30,6 @@ struct PythonSourceTermData final
//! Python object computing source term values.
PythonSourceTermPythonSideInterface* source_term_object;
//! DOF table of the entire domain.
NumLib::LocalToGlobalIndexMap const& dof_table_bulk;
//! Mesh ID of the entire domain.
std::size_t const bulk_mesh_id;
......@@ -49,7 +46,7 @@ class PythonSourceTerm final : public ProcessLib::SourceTerm
{
public:
explicit PythonSourceTerm(
NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
PythonSourceTermData&& source_term_data,
unsigned const integration_order, unsigned const shapefunction_order,
unsigned const global_dim, bool const flush_stdout);
......@@ -61,9 +58,6 @@ private:
//! Auxiliary data.
PythonSourceTermData _source_term_data;
//! Local dof table for the boundary mesh.
std::unique_ptr<NumLib::LocalToGlobalIndexMap> _dof_table_source_term;
//! Local assemblers for all elements of the source term mesh.
std::vector<std::unique_ptr<PythonSourceTermLocalAssemblerInterface>>
_local_assemblers;
......
......@@ -99,10 +99,10 @@ public:
unsigned const num_integration_points =
_integration_method.getNumberOfPoints();
auto const num_var = _data.dof_table_bulk.getNumberOfVariables();
auto const num_var = dof_table_source_term.getNumberOfVariables();
auto const num_nodes = ShapeFunction::NPOINTS;
auto const num_comp_total =
_data.dof_table_bulk.getNumberOfComponents();
dof_table_source_term.getNumberOfComponents();
auto const& bulk_node_ids_map =
*_data.source_term_mesh.getProperties()
......@@ -115,7 +115,7 @@ public:
for (int var = 0; var < num_var; ++var)
{
auto const num_comp =
_data.dof_table_bulk.getNumberOfVariableComponents(var);
dof_table_source_term.getNumberOfVariableComponents(var);
for (int comp = 0; comp < num_comp; ++comp)
{
auto const global_component =
......@@ -132,7 +132,7 @@ public:
MeshLib::MeshItemType::Node,
bulk_node_id};
auto const dof_idx =
_data.dof_table_bulk.getGlobalIndex(loc, var, comp);
dof_table_source_term.getGlobalIndex(loc, var, comp);
if (dof_idx == NumLib::MeshComponentMap::nop)
{
// TODO extend Python BC to mixed FEM ansatz functions
......
......@@ -9,6 +9,8 @@
#pragma once
#include <memory>
#include "NumLib/DOF/LocalToGlobalIndexMap.h"
#include "ProcessLib/Parameter/Parameter.h"
......@@ -18,8 +20,8 @@ class SourceTerm
{
public:
explicit SourceTerm(
const NumLib::LocalToGlobalIndexMap& source_term_dof_table)
: _source_term_dof_table(source_term_dof_table)
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table)
: _source_term_dof_table{std::move(source_term_dof_table)}
{
}
......@@ -29,7 +31,7 @@ public:
virtual ~SourceTerm() = default;
protected:
NumLib::LocalToGlobalIndexMap const& _source_term_dof_table;
std::unique_ptr<NumLib::LocalToGlobalIndexMap> const _source_term_dof_table;
};
} // namespace ProcessLib
......@@ -15,11 +15,11 @@ namespace ProcessLib
{
VolumetricSourceTerm::VolumetricSourceTerm(
MeshLib::Mesh const& source_term_mesh,
NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
unsigned const integration_order, unsigned const shapefunction_order,
int const variable_id, int const component_id,
Parameter<double> const& volumetric_source_term)
: SourceTerm(source_term_dof_table),
: SourceTerm(std::move(source_term_dof_table)),
_volumetric_source_term(volumetric_source_term)
{
// check basic data consistency
......@@ -42,7 +42,7 @@ VolumetricSourceTerm::VolumetricSourceTerm(
ProcessLib::createLocalAssemblers<VolumetricSourceTermLocalAssembler>(
source_term_mesh.getDimension(), source_term_mesh.getElements(),
source_term_dof_table, shapefunction_order, _local_assemblers,
*_source_term_dof_table, shapefunction_order, _local_assemblers,
source_term_mesh.isAxiallySymmetric(), integration_order,
_volumetric_source_term);
}
......@@ -56,7 +56,7 @@ void VolumetricSourceTerm::integrate(const double t, GlobalVector const& /*x*/,
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberOnDereferenced(
&VolumetricSourceTermLocalAssemblerInterface::integrate,
_local_assemblers, _source_term_dof_table, t, b);
_local_assemblers, *_source_term_dof_table, t, b);
}
} // namespace ProcessLib
......@@ -22,7 +22,7 @@ class VolumetricSourceTerm final : public SourceTerm
public:
VolumetricSourceTerm(
MeshLib::Mesh const& source_term_mesh,
NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
unsigned const integration_order, unsigned const shapefunction_order,
int const variable_id, int const component_id,
Parameter<double> const& volumetric_source_term);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment