Commit cfed59c8 authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Merge branch 'fix/MovingBodyBC' into 'master'

Fix/moving body bc

See merge request !852
parents 3f12b281 218efb1c
......@@ -91,6 +91,7 @@ v4.4.1
**IncNavierStokesSolver**
- Fix an initialisation issue when using an additional advective field (!779)
- Fix MovingBody boundary condition (!852)
**Utilities**
- Fix vtkToFld missing dependency which prevented compiling with VTK 7.1 (!808)
......
......@@ -1075,18 +1075,8 @@ void Mapping::v_UpdateBCs( const NekDouble time)
int nbnds = m_fields[0]->GetBndConditions().num_elements();
// Declare variables
Array<OneD, int> BCtoElmtID;
Array<OneD, int> BCtoTraceID;
Array<OneD, const SpatialDomains::BoundaryConditionShPtr> BndConds;
Array<OneD, MultiRegions::ExpListSharedPtr> BndExp;
StdRegions::StdExpansionSharedPtr elmt;
StdRegions::StdExpansionSharedPtr Bc;
Array<OneD, NekDouble> ElmtVal(physTot, 0.0);
Array<OneD, NekDouble> BndVal(physTot, 0.0);
Array<OneD, NekDouble> coordVelElmt(physTot, 0.0);
Array<OneD, NekDouble> coordVelBnd(physTot, 0.0);
Array<OneD, NekDouble> Vals(physTot, 0.0);
Array<OneD, bool> isDirichlet(nfields);
......@@ -1180,66 +1170,26 @@ void Mapping::v_UpdateBCs( const NekDouble time)
{
BndConds = m_fields[i]->GetBndConditions();
BndExp = m_fields[i]->GetBndCondExpansions();
// Loop boundary conditions again to get correct
// values for cnt
int cnt = 0;
for(int m = 0 ; m < nbnds; ++m)
if( BndConds[n]->GetUserDefined() =="" ||
BndConds[n]->GetUserDefined() =="MovingBody")
{
int exp_size = BndExp[m]->GetExpSize();
if (m==n && isDirichlet[i])
{
for (int j = 0; j < exp_size; ++j, cnt++)
{
m_fields[i]->GetBoundaryToElmtMap(BCtoElmtID,
BCtoTraceID);
/// Casting the bnd exp to the specific case
Bc = std::dynamic_pointer_cast<
StdRegions::StdExpansion>
(BndExp[n]->GetExp(j));
// Get element expansion
elmt = m_fields[i]->GetExp(BCtoElmtID[cnt]);
// Get values on the element
ElmtVal = values[i] +
m_fields[i]->GetPhys_Offset(
BCtoElmtID[cnt]);
// Get values on boundary
elmt->GetTracePhysVals(BCtoTraceID[cnt],
Bc, ElmtVal, BndVal);
// Pointer to value that should be updated
Vals = BndExp[n]->UpdatePhys()
+ BndExp[n]->GetPhys_Offset(j);
// Copy result
Vmath::Vcopy(Bc->GetTotPoints(),
BndVal, 1, Vals, 1);
// Apply MovingBody correction
if ( (i<nvel) &&
BndConds[n]->GetUserDefined() ==
"MovingBody" )
{
// get coordVel in the element
coordVelElmt = coordVel[i] +
m_fields[i]->GetPhys_Offset(
BCtoElmtID[cnt]);
// Get values on boundary
elmt->GetTracePhysVals(
BCtoTraceID[cnt], Bc,
coordVelElmt, coordVelBnd);
// Apply correction
Vmath::Vadd(Bc->GetTotPoints(),
coordVelBnd, 1,
Vals, 1, Vals, 1);
}
}
}
else // setting if m!=n
m_fields[i]->ExtractPhysToBnd(n,
values[i], BndExp[n]->UpdatePhys());
// Apply MovingBody correction
if ( (i<nvel) &&
BndConds[n]->GetUserDefined() ==
"MovingBody" )
{
cnt += exp_size;
// Get coordinate velocity on boundary
Array<OneD, NekDouble> coordVelBnd(BndExp[n]->GetTotPoints());
m_fields[i]->ExtractPhysToBnd(n, coordVel[i], coordVelBnd);
// Apply correction
Vmath::Vadd(BndExp[n]->GetTotPoints(),
coordVelBnd, 1,
BndExp[n]->UpdatePhys(), 1,
BndExp[n]->UpdatePhys(), 1);
}
}
}
......@@ -1256,12 +1206,16 @@ void Mapping::v_UpdateBCs( const NekDouble time)
if ( BndConds[n]->GetBoundaryConditionType() ==
SpatialDomains::eDirichlet)
{
BndExp[n]->FwdTrans_BndConstrained(BndExp[n]->GetPhys(),
BndExp[n]->UpdateCoeffs());
if (m_fields[i]->GetExpType() == MultiRegions::e3DH1D)
if( BndConds[n]->GetUserDefined() =="" ||
BndConds[n]->GetUserDefined() =="MovingBody")
{
BndExp[n]->HomogeneousFwdTrans(BndExp[n]->GetCoeffs(),
BndExp[n]->UpdateCoeffs());
BndExp[n]->FwdTrans_BndConstrained(BndExp[n]->GetPhys(),
BndExp[n]->UpdateCoeffs());
if (m_fields[i]->GetExpType() == MultiRegions::e3DH1D)
{
BndExp[n]->HomogeneousFwdTrans(BndExp[n]->GetCoeffs(),
BndExp[n]->UpdateCoeffs());
}
}
}
}
......
......@@ -2350,22 +2350,6 @@ namespace Nektar
ASSERTL0(false, "This type of BC not implemented yet");
}
}
else if (boost::iequals(m_bndConditions[i]->GetUserDefined(),
"MovingBody"))
{
locExpList = m_bndCondExpansions[i];
if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eDirichlet)
{
locExpList->FwdTrans_IterPerExp(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
else
{
ASSERTL0(false, "This type of BC not implemented yet");
}
}
}
}
} // end of namespace
......
......@@ -251,9 +251,7 @@ namespace Nektar
for (n = 0; n < m_bndCondExpansions.num_elements(); ++n)
{
if (time == 0.0 ||
m_bndConditions[n]->IsTimeDependent() ||
boost::iequals(m_bndConditions[n]->GetUserDefined(),
"MovingBody"))
m_bndConditions[n]->IsTimeDependent() )
{
m_bndCondExpansions[n]->HomogeneousFwdTrans(
m_bndCondExpansions[n]->GetCoeffs(),
......
......@@ -587,6 +587,8 @@ namespace Nektar
{
velbc[i] = Array<OneD, NekDouble>
(VelBndExp[i][n]->GetTotPoints(), 0.0);
VelBndExp[i][n]->SetWaveSpace(
m_fields[m_velocity[i]]->GetWaveSpace());
VelBndExp[i][n]->BwdTrans(VelBndExp[i][n]->GetCoeffs(),
velbc[i]);
}
......
......@@ -7,25 +7,17 @@
<file description="Session File">CylFlow_MovBody.xml</file>
</files>
<metrics>
L 2 error (variable u) : 55.4979
L inf error (variable u) : 1.44442
L 2 error (variable v) : 3.73646
L inf error (variable v) : 0.670941
L 2 error (variable w) : 0.00651794
L inf error (variable w) : 0.00445146
L 2 error (variable p) : 167.909
L inf error (variable p) : 5.6965
<metric type="L2" id="1">
<value variable="u" tolerance="1e-12">55.4979</value>
<value variable="v" tolerance="1e-12">3.73646</value>
<value variable="w" tolerance="1e-12">0.00651794</value>
<value variable="w" tolerance="1e-12">0.00651852</value>
<value variable="p" tolerance="1e-12">167.909</value>
</metric>
<metric type="Linf" id="2">
<value variable="u" tolerance="1e-12">1.44442</value>
<value variable="v" tolerance="1e-12">0.670941</value>
<value variable="w" tolerance="1e-12">0.00445146</value>
<value variable="p" tolerance="1e-12">5.6965</value>
<value variable="v" tolerance="1e-12">0.670929</value>
<value variable="w" tolerance="1e-12">0.00444785</value>
<value variable="p" tolerance="1e-12">5.69645</value>
</metric>
</metrics>
</test>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment