Skip to content
Snippets Groups Projects
Commit ec4382eb authored by Timo Koch's avatar Timo Koch
Browse files

[fcdiamond][assembler] Handle ghosts in local assembler

parent dd169e13
No related branches found
No related tags found
1 merge request!3222[fcdiamond] Add Navier-Stokes momentum model and tests
...@@ -144,8 +144,27 @@ public: ...@@ -144,8 +144,27 @@ public:
maybeAssembleCouplingBlocks(residual); maybeAssembleCouplingBlocks(residual);
} }
else else
DUNE_THROW(Dune::NotImplemented, "Ghost elements not supported"); {
const auto numLocalFaces = this->element().subEntities(1);
for (int i = 0; i < numLocalFaces; ++i)
{
// do not change the non-ghost vertices
const auto face = this->element().template subEntity<1>(i);
if (face.partitionType() == Dune::InteriorEntity || face.partitionType() == Dune::BorderEntity)
continue;
// set main diagonal entries for the vertex
const auto dofIndex = gridGeometry.dofMapper().index(face);
typedef typename JacobianMatrix::block_type BlockType;
BlockType &J = jac[dofIndex][dofIndex];
for (int j = 0; j < BlockType::rows; ++j)
J[j][j] = 1.0;
// set residual for the vertex
res[dofIndex] = 0;
}
}
auto applyDirichlet = [&] (const auto& scvI, auto applyDirichlet = [&] (const auto& scvI,
const auto& dirichletValues, const auto& dirichletValues,
...@@ -390,14 +409,14 @@ public: ...@@ -390,14 +409,14 @@ public:
{ {
// update the volume variables and compute element residual // update the volume variables and compute element residual
elemSol[scv.localDofIndex()][pvIdx] = priVar; elemSol[scv.localDofIndex()][pvIdx] = priVar;
deflectionHelper.deflect(elemSol, scv, this->problem()); deflectionHelper.deflect(elemSol, scv, problem);
this->asImp_().maybeUpdateCouplingContext(scv, elemSol, pvIdx); this->asImp_().maybeUpdateCouplingContext(scv, elemSol, pvIdx);
return this->evalLocalResidual(); return this->evalLocalResidual();
}; };
// derive the residuals numerically // derive the residuals numerically
static const NumericEpsilon<Scalar, numEq> eps_{this->problem().paramGroup()}; static const NumericEpsilon<Scalar, numEq> eps_{problem.paramGroup()};
static const int numDiffMethod = getParamFromGroup<int>(this->problem().paramGroup(), "Assembly.NumericDifferenceMethod"); static const int numDiffMethod = getParamFromGroup<int>(problem.paramGroup(), "Assembly.NumericDifferenceMethod");
NumericDifferentiation::partialDerivative(evalResiduals, elemSol[scv.localDofIndex()][pvIdx], partialDerivs, origResiduals, NumericDifferentiation::partialDerivative(evalResiduals, elemSol[scv.localDofIndex()][pvIdx], partialDerivs, origResiduals,
eps_(elemSol[scv.localDofIndex()][pvIdx], pvIdx), numDiffMethod); eps_(elemSol[scv.localDofIndex()][pvIdx], pvIdx), numDiffMethod);
...@@ -468,9 +487,10 @@ public: ...@@ -468,9 +487,10 @@ public:
DUNE_THROW(Dune::NotImplemented, "partial reassembly for explicit time discretization"); DUNE_THROW(Dune::NotImplemented, "partial reassembly for explicit time discretization");
// get some aliases for convenience // get some aliases for convenience
const auto& problem = this->asImp_().problem();
const auto& element = this->element(); const auto& element = this->element();
const auto& fvGeometry = this->fvGeometry(); const auto& fvGeometry = this->fvGeometry();
const auto& curSol = this->curSol(); const auto& curSol = this->asImp_().curSol();
auto&& curElemVolVars = this->curElemVolVars(); auto&& curElemVolVars = this->curElemVolVars();
// get the vecor of the acutal element residuals // get the vecor of the acutal element residuals
...@@ -508,13 +528,13 @@ public: ...@@ -508,13 +528,13 @@ public:
{ {
// auto partialDerivsTmp = partialDerivs; // auto partialDerivsTmp = partialDerivs;
elemSol[scv.localDofIndex()][pvIdx] = priVar; elemSol[scv.localDofIndex()][pvIdx] = priVar;
curVolVars.update(elemSol, this->problem(), element, scv); curVolVars.update(elemSol, problem, element, scv);
return this->evalLocalStorageResidual(); return this->evalLocalStorageResidual();
}; };
// derive the residuals numerically // derive the residuals numerically
static const NumericEpsilon<Scalar, numEq> eps_{this->problem().paramGroup()}; static const NumericEpsilon<Scalar, numEq> eps_{problem.paramGroup()};
static const int numDiffMethod = getParamFromGroup<int>(this->problem().paramGroup(), "Assembly.NumericDifferenceMethod"); static const int numDiffMethod = getParamFromGroup<int>(problem.paramGroup(), "Assembly.NumericDifferenceMethod");
NumericDifferentiation::partialDerivative(evalStorage, elemSol[scv.localDofIndex()][pvIdx], partialDerivs, origStorageResiduals, NumericDifferentiation::partialDerivative(evalStorage, elemSol[scv.localDofIndex()][pvIdx], partialDerivs, origStorageResiduals,
eps_(elemSol[scv.localDofIndex()][pvIdx], pvIdx), numDiffMethod); eps_(elemSol[scv.localDofIndex()][pvIdx], pvIdx), numDiffMethod);
...@@ -579,7 +599,7 @@ public: ...@@ -579,7 +599,7 @@ public:
// get some aliases for convenience // get some aliases for convenience
const auto& element = this->element(); const auto& element = this->element();
const auto& fvGeometry = this->fvGeometry(); const auto& fvGeometry = this->fvGeometry();
const auto& problem = this->problem(); const auto& problem = this->asImp_().problem();
const auto& curElemVolVars = this->curElemVolVars(); const auto& curElemVolVars = this->curElemVolVars();
const auto& elemFluxVarsCache = this->elemFluxVarsCache(); const auto& elemFluxVarsCache = this->elemFluxVarsCache();
...@@ -699,7 +719,7 @@ public: ...@@ -699,7 +719,7 @@ public:
// get some aliases for convenience // get some aliases for convenience
const auto& element = this->element(); const auto& element = this->element();
const auto& fvGeometry = this->fvGeometry(); const auto& fvGeometry = this->fvGeometry();
const auto& problem = this->problem(); const auto& problem = this->asImp_().problem();
const auto& curElemVolVars = this->curElemVolVars(); const auto& curElemVolVars = this->curElemVolVars();
// get the vector of the actual element residuals // get the vector of the actual element residuals
......
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