Skip to content
Snippets Groups Projects
Commit fc3f3ad7 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL] Move BCs to Process. Small generalizations.

 - initializeNeumannBcs() is no longer needed.
 - make _neumann_bcs a vector of unique_ptr's.
parent e4ba29d8
No related branches found
No related tags found
No related merge requests found
......@@ -24,8 +24,6 @@
#include "FileIO/VtkIO/VtuInterface.h"
#include "MathLib/LinAlg/ApplyKnownSolution.h"
#include "MeshLib/MeshSubset.h"
#include "MeshGeoToolsLib/MeshNodeSearcher.h"
......@@ -153,14 +151,17 @@ public:
_local_assemblers,
*_hydraulic_conductivity,
_integration_order);
}
void initializeBoundaryConditions() override
{
DBUG("Initialize boundary conditions.");
MeshGeoToolsLib::MeshNodeSearcher& hydraulic_head_mesh_node_searcher =
MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher(
_hydraulic_head->getMesh());
_hydraulic_head->initializeDirichletBCs(
std::back_inserter(_dirichlet_bcs),
std::back_inserter(this->_dirichlet_bcs),
hydraulic_head_mesh_node_searcher,
*this->_local_to_global_index_map,
0);
......@@ -176,7 +177,7 @@ public:
// Create a neumann BC for the hydraulic head storing them in the
// _neumann_bcs vector.
_hydraulic_head->createNeumannBcs(
std::back_inserter(_neumann_bcs),
std::back_inserter(this->_neumann_bcs),
hydraulic_head_mesh_element_searcher,
this->_global_setup,
_integration_order,
......@@ -184,8 +185,6 @@ public:
0,
*_mesh_subset_all_nodes);
}
Process<GlobalSetup>::initializeNeumannBcs(_neumann_bcs);
}
void initializeMeshSubsets(MeshLib::Mesh const& mesh) override
......@@ -230,14 +229,6 @@ public:
this->_global_setup.execute(*this->_global_assembler,
_local_assemblers);
// Call global assembler for each Neumann boundary local assembler.
for (auto bc : _neumann_bcs)
bc->integrate(this->_global_setup);
for (auto const& bc : _dirichlet_bcs)
MathLib::applyKnownSolution(*this->_A, *this->_rhs, *this->_x,
bc.global_ids, bc.values);
return true;
}
......@@ -294,13 +285,8 @@ public:
~GroundwaterFlowProcess()
{
for (auto p : _neumann_bcs)
delete p;
for (auto p : _local_assemblers)
delete p;
delete _mesh_subset_all_nodes;
}
private:
......@@ -314,9 +300,6 @@ private:
typename GlobalSetup::MatrixType, typename GlobalSetup::VectorType>;
std::vector<LocalAssembler*> _local_assemblers;
std::vector<DirichletBc<GlobalIndexType>> _dirichlet_bcs;
std::vector<NeumannBc<GlobalSetup>*> _neumann_bcs;
};
} // namespace ProcessLib
......
......@@ -13,9 +13,10 @@
#include <string>
#include "AssemblerLib/ComputeSparsityPattern.h"
#include "AssemblerLib/VectorMatrixAssembler.h"
#include "AssemblerLib/LocalToGlobalIndexMap.h"
#include "AssemblerLib/VectorMatrixAssembler.h"
#include "BaseLib/ConfigTreeNew.h"
#include "MathLib/LinAlg/ApplyKnownSolution.h"
#include "MathLib/LinAlg/SetMatrixSparsity.h"
#include "MeshLib/MeshSubsets.h"
......@@ -59,6 +60,8 @@ public:
/// Creates mesh subsets, i.e. components, for given mesh.
virtual void initializeMeshSubsets(MeshLib::Mesh const& mesh) = 0;
virtual void initializeBoundaryConditions() = 0;
void initialize()
{
DBUG("Initialize process.");
......@@ -83,11 +86,10 @@ public:
new GlobalAssembler(*_A, *_rhs, *_local_to_global_index_map));
init(); // Execute proces specific initialization.
}
void initializeNeumannBcs(std::vector<NeumannBc<GlobalSetup>*> const& bcs)
{
for (auto bc : bcs)
initializeBoundaryConditions();
for (auto& bc : _neumann_bcs)
bc->initialize(_global_setup, *_A, *_rhs, _mesh.getDimension());
}
......@@ -98,6 +100,14 @@ public:
bool const result = assemble(delta_t);
// Call global assembler for each Neumann boundary local assembler.
for (auto const& bc : _neumann_bcs)
bc->integrate(_global_setup);
for (auto const& bc : _dirichlet_bcs)
MathLib::applyKnownSolution(*_A, *_rhs, *_x,
bc.global_ids, bc.values);
_linear_solver->solve(*_rhs, *_x);
return result;
}
......@@ -184,6 +194,9 @@ protected:
std::unique_ptr<typename GlobalSetup::VectorType> _x;
AssemblerLib::SparsityPattern _sparsity_pattern;
std::vector<DirichletBc<GlobalIndexType>> _dirichlet_bcs;
std::vector<std::unique_ptr<NeumannBc<GlobalSetup>>> _neumann_bcs;
};
} // namespace ProcessLib
......
......@@ -81,8 +81,9 @@ public:
for (auto& config : _neumann_bc_configs)
{
config->initialize(searcher);
bcs++ = new NeumannBc<GlobalSetup>(*config,
std::forward<Args>(args)...);
bcs++ = std::unique_ptr<NeumannBc<GlobalSetup>>{
new NeumannBc<GlobalSetup>(*config,
std::forward<Args>(args)...)};
}
}
......
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