Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python BCs #2170

Merged
merged 23 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[PL] extended BC interface
  • Loading branch information
chleh committed Aug 17, 2018
commit 10145297f345506ed5424eb39cecc8b5ce5b9fb3
5 changes: 3 additions & 2 deletions ProcessLib/BoundaryCondition/BoundaryCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ class BoundaryCondition
//! Applies natural BCs (i.e. non-Dirichlet BCs) to the stiffness matrix
//! \c K and the vector \c b.
virtual void applyNaturalBC(const double /*t*/, GlobalVector const& /*x*/,
GlobalMatrix& /*K*/, GlobalVector& /*b*/)
GlobalMatrix& /*K*/, GlobalVector& /*b*/,
GlobalMatrix* /*Jac*/)
{
// By default it is assumed that the BC is not a natural BC. Therefore
// there is nothing to do here.
}

//! Writes the values of essential BCs to \c bc_values.
virtual void getEssentialBCValues(
const double /*t*/,
const double /*t*/, GlobalVector const& /*x*/,
NumLib::IndexValueVector<GlobalIndexType>& /*bc_values*/) const
{
// By default it is assumed that the BC is not an essential BC.
Expand Down
7 changes: 4 additions & 3 deletions ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ namespace ProcessLib
void BoundaryConditionCollection::applyNaturalBC(const double t,
GlobalVector const& x,
GlobalMatrix& K,
GlobalVector& b)
GlobalVector& b,
GlobalMatrix* Jac)
{
for (auto const& bc : _boundary_conditions)
bc->applyNaturalBC(t, x, K, b);
bc->applyNaturalBC(t, x, K, b, Jac);
}

void BoundaryConditionCollection::addBCsForProcessVariables(
Expand All @@ -43,4 +44,4 @@ void BoundaryConditionCollection::addBCsForProcessVariables(
// object if needed.
_dirichlet_bcs.resize(_boundary_conditions.size());
}
}
} // namespace ProcessLib
6 changes: 3 additions & 3 deletions ProcessLib/BoundaryCondition/BoundaryConditionCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ class BoundaryConditionCollection final
}

void applyNaturalBC(const double t, GlobalVector const& x, GlobalMatrix& K,
GlobalVector& b);
GlobalVector& b, GlobalMatrix* Jac);

std::vector<NumLib::IndexValueVector<GlobalIndexType>> const*
getKnownSolutions(double const t) const
getKnownSolutions(double const t, GlobalVector const& x) const
{
auto const n_bcs = _boundary_conditions.size();
for (std::size_t i=0; i<n_bcs; ++i) {
auto const& bc = *_boundary_conditions[i];
auto& dirichlet_storage = _dirichlet_bcs[i];
bc.getEssentialBCValues(t, dirichlet_storage);
bc.getEssentialBCValues(t, x, dirichlet_storage);
}
return &_dirichlet_bcs;
}
Expand Down
4 changes: 2 additions & 2 deletions ProcessLib/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Process::assemble(const double t, GlobalVector const& x, GlobalMatrix& M,

const auto pcs_id =
(_coupled_solutions) != nullptr ? _coupled_solutions->process_id : 0;
_boundary_conditions[pcs_id].applyNaturalBC(t, x, K, b);
_boundary_conditions[pcs_id].applyNaturalBC(t, x, K, b, nullptr);

_source_term_collections[pcs_id].integrateNodalSourceTerms(t, b);
}
Expand All @@ -207,7 +207,7 @@ void Process::assembleWithJacobian(const double t, GlobalVector const& x,
// TODO: apply BCs to Jacobian.
const auto pcs_id =
(_coupled_solutions) != nullptr ? _coupled_solutions->process_id : 0;
_boundary_conditions[pcs_id].applyNaturalBC(t, x, K, b);
_boundary_conditions[pcs_id].applyNaturalBC(t, x, K, b, &Jac);
}

void Process::constructDofTable()
Expand Down
6 changes: 3 additions & 3 deletions ProcessLib/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#include "NumLib/ODESolver/ODESystem.h"
#include "NumLib/ODESolver/TimeDiscretization.h"
#include "ProcessLib/BoundaryCondition/BoundaryConditionCollection.h"
#include "ProcessLib/SourceTerms/SourceTermCollection.h"
#include "ProcessLib/Output/CachedSecondaryVariable.h"
#include "ProcessLib/Output/ExtrapolatorData.h"
#include "ProcessLib/Output/IntegrationPointWriter.h"
#include "ProcessLib/Output/SecondaryVariable.h"
#include "ProcessLib/Parameter/Parameter.h"
#include "ProcessLib/SourceTerms/NodalSourceTerm.h"
#include "ProcessLib/SourceTerms/SourceTermCollection.h"

#include "AbstractJacobianAssembler.h"
#include "ProcessVariable.h"
Expand Down Expand Up @@ -103,11 +103,11 @@ class Process
GlobalMatrix& Jac) final;

std::vector<NumLib::IndexValueVector<GlobalIndexType>> const*
getKnownSolutions(double const t) const final
getKnownSolutions(double const t, GlobalVector const& x) const final
{
const auto pcs_id =
(_coupled_solutions) ? _coupled_solutions->process_id : 0;
return _boundary_conditions[pcs_id].getKnownSolutions(t);
return _boundary_conditions[pcs_id].getKnownSolutions(t, x);
}

virtual NumLib::LocalToGlobalIndexMap const& getDOFTable(
Expand Down