Commit 08bd8a22 authored by Dave Moxey's avatar Dave Moxey

Removed integer from EvaluateBoundaryConditions as it is no longer required,...

Removed integer from EvaluateBoundaryConditions as it is no longer required, and added ExpList::ExtractFileBCs to reduce code duplication
parent 50349b86
...@@ -83,7 +83,7 @@ namespace Nektar ...@@ -83,7 +83,7 @@ namespace Nektar
SpatialDomains::BoundaryConditions bcs(m_session, graph1D); SpatialDomains::BoundaryConditions bcs(m_session, graph1D);
GenerateBoundaryConditionExpansion(graph1D,bcs,variable); GenerateBoundaryConditionExpansion(graph1D,bcs,variable);
EvaluateBoundaryConditions(); EvaluateBoundaryConditions(0.0, variable);
ApplyGeomInfo(); ApplyGeomInfo();
map<int,int> periodicVertices; map<int,int> periodicVertices;
...@@ -172,7 +172,7 @@ namespace Nektar ...@@ -172,7 +172,7 @@ namespace Nektar
i); i);
//1. c) Evaluate the boundary conditions //1. c) Evaluate the boundary conditions
EvaluateBoundaryConditions(); EvaluateBoundaryConditions(0.0, variable);
//ApplyGeomInfo(); //ApplyGeomInfo();
//2. Set up trace information //2. Set up trace information
...@@ -1231,11 +1231,10 @@ namespace Nektar ...@@ -1231,11 +1231,10 @@ namespace Nektar
* @param bndConditions Information about the boundary conditions. * @param bndConditions Information about the boundary conditions.
*/ */
void DisContField1D::v_EvaluateBoundaryConditions( void DisContField1D::v_EvaluateBoundaryConditions(
const NekDouble time, const NekDouble time,
int var, const std::string varName,
std::string varName, const NekDouble x2_in,
const NekDouble x2_in, const NekDouble x3_in)
const NekDouble x3_in)
{ {
int i; int i;
......
...@@ -223,11 +223,10 @@ namespace Nektar ...@@ -223,11 +223,10 @@ namespace Nektar
/// Evaluate all boundary conditions at a given time.. /// Evaluate all boundary conditions at a given time..
virtual void v_EvaluateBoundaryConditions( virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0, const NekDouble time = 0.0,
int var = 0, const std::string varName = "",
std::string varName = "", const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x2_in = NekConstants::kNekUnsetDouble, const NekDouble x3_in = NekConstants::kNekUnsetDouble);
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
/// Solve the Helmholtz equation. /// Solve the Helmholtz equation.
virtual void v_HelmSolve( virtual void v_HelmSolve(
......
...@@ -102,7 +102,7 @@ namespace Nektar ...@@ -102,7 +102,7 @@ namespace Nektar
if (DeclareCoeffPhysArrays) if (DeclareCoeffPhysArrays)
{ {
EvaluateBoundaryConditions(); EvaluateBoundaryConditions(0.0, variable);
} }
ApplyGeomInfo(); ApplyGeomInfo();
...@@ -184,7 +184,7 @@ namespace Nektar ...@@ -184,7 +184,7 @@ namespace Nektar
if (DeclareCoeffPhysArrays) if (DeclareCoeffPhysArrays)
{ {
EvaluateBoundaryConditions(); EvaluateBoundaryConditions(0.0, variable);
} }
if (!SameTypeOfBoundaryConditions(In)) if (!SameTypeOfBoundaryConditions(In))
...@@ -2117,11 +2117,10 @@ namespace Nektar ...@@ -2117,11 +2117,10 @@ namespace Nektar
* case when the method is called from the constructor. * case when the method is called from the constructor.
*/ */
void DisContField2D::v_EvaluateBoundaryConditions( void DisContField2D::v_EvaluateBoundaryConditions(
const NekDouble time, const NekDouble time,
int var, const std::string varName,
std::string varName, const NekDouble x2_in,
const NekDouble x2_in, const NekDouble x3_in)
const NekDouble x3_in)
{ {
int i; int i;
int npoints; int npoints;
...@@ -2155,57 +2154,13 @@ namespace Nektar ...@@ -2155,57 +2154,13 @@ namespace Nektar
if (m_bndConditions[i]->GetBoundaryConditionType() if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eDirichlet) == SpatialDomains::eDirichlet)
{ {
string filebcs = boost::static_pointer_cast< string filebcs = boost::static_pointer_cast<
SpatialDomains::DirichletBoundaryCondition>( SpatialDomains::DirichletBoundaryCondition>(
m_bndConditions[i])->m_filename; m_bndConditions[i])->m_filename;
if (filebcs != "") if (filebcs != "")
{ {
string varString = filebcs.substr( ExtractFileBCs(filebcs, varName, locExpList);
0, filebcs.find_last_of("."));
int len = varString.length();
varString = varString.substr(len-1, len);
cout << "Boundary condition from file:"
<< filebcs << endl;
cout << "var = " << var << endl;
cout << "varName = " << varName << endl;
std::vector<LibUtilities::
FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIO f(m_session->GetComm());
f.Import(filebcs, FieldDef, FieldData);
const std::string varNameFld = FieldDef[0]->
m_fields[var];
cout << "varNameFld = " << varNameFld << endl;
if (varNameFld == varName)
{
// Copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[var],
locExpList->UpdateCoeffs());
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
else
{
ASSERTL0(
false,
"BCs fields order in session file do not "
"match variable order in the fld file");
}
} }
else else
{ {
...@@ -2217,11 +2172,11 @@ namespace Nektar ...@@ -2217,11 +2172,11 @@ namespace Nektar
condition.Evaluate(x0, x1, x2, time, condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys()); locExpList->UpdatePhys());
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
} }
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
} }
else if (m_bndConditions[i]->GetBoundaryConditionType() else if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eNeumann) == SpatialDomains::eNeumann)
...@@ -2229,53 +2184,10 @@ namespace Nektar ...@@ -2229,53 +2184,10 @@ namespace Nektar
string filebcs = boost::static_pointer_cast< string filebcs = boost::static_pointer_cast<
SpatialDomains::NeumannBoundaryCondition>( SpatialDomains::NeumannBoundaryCondition>(
m_bndConditions[i])->m_filename; m_bndConditions[i])->m_filename;
if (filebcs != "") if (filebcs != "")
{ {
string varString = filebcs.substr( ExtractFileBCs(filebcs, varName, locExpList);
0, filebcs.find_last_of("."));
int len = varString.length();
varString = varString.substr(len-1, len);
cout << "Boundary condition from file:"
<< filebcs << endl;
cout << "var = " << var << endl;
cout << "varName = " << varName << endl;
std::vector<LibUtilities::
FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIO f(m_session->GetComm());
f.Import(filebcs, FieldDef, FieldData);
const std::string varNameFld = FieldDef[0]->
m_fields[var];
cout << "varNameFld = " << varNameFld << endl;
if (varNameFld == varName)
{
// Copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[var],
locExpList->UpdateCoeffs());
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
else
{
ASSERTL0(
false,
"BCs fields order in session file do not "
"match variable order in the fld file");
}
} }
else else
{ {
...@@ -2286,11 +2198,11 @@ namespace Nektar ...@@ -2286,11 +2198,11 @@ namespace Nektar
m_neumannCondition; m_neumannCondition;
condition.Evaluate(x0, x1, x2, time, condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys()); locExpList->UpdatePhys());
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
} }
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
} }
else if (m_bndConditions[i]->GetBoundaryConditionType() else if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eRobin) == SpatialDomains::eRobin)
...@@ -2301,55 +2213,7 @@ namespace Nektar ...@@ -2301,55 +2213,7 @@ namespace Nektar
if (filebcs != "") if (filebcs != "")
{ {
// Never tested ExtractFileBCs(filebcs, varName, locExpList);
string varString = filebcs.substr(
0, filebcs.find_last_of("."));
int len = varString.length();
varString = varString.substr(len-1, len);
std::vector<LibUtilities::
FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIO f(m_session->GetComm());
f.Import(filebcs, FieldDef, FieldData);
const std::string varNameFld = FieldDef[0]->
m_fields[var];
if (varNameFld == varName)
{
// Copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[var],
locExpList->UpdateCoeffs());
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
LibUtilities::Equation coeff =
boost::static_pointer_cast<SpatialDomains::
RobinBoundaryCondition>(
m_bndConditions[i])->
m_robinPrimitiveCoeff;
// Array<OneD,NekDouble> timeArray(npoints, time);
// Put primitive coefficient into the physical
// space storage
coeff.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
}
else
{
ASSERTL0(
false,
"BCs fields order in session file do not "
"match variable order in the fld file");
}
} }
else else
{ {
...@@ -2358,22 +2222,22 @@ namespace Nektar ...@@ -2358,22 +2222,22 @@ namespace Nektar
SpatialDomains::RobinBoundaryCondition> SpatialDomains::RobinBoundaryCondition>
(m_bndConditions[i])-> (m_bndConditions[i])->
m_robinFunction; m_robinFunction;
LibUtilities::Equation coeff =
boost::static_pointer_cast<
SpatialDomains::RobinBoundaryCondition>
(m_bndConditions[i])->
m_robinPrimitiveCoeff;
condition.Evaluate(x0, x1, x2, time, condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys()); locExpList->UpdatePhys());
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
// put primitive coefficient into the physical
// space storage
coeff.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
} }
LibUtilities::Equation coeff =
boost::static_pointer_cast<
SpatialDomains::RobinBoundaryCondition>(
m_bndConditions[i])->m_robinPrimitiveCoeff;
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
// put primitive coefficient into the physical
// space storage
coeff.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
} }
else else
{ {
......
...@@ -249,11 +249,10 @@ namespace Nektar ...@@ -249,11 +249,10 @@ namespace Nektar
} }
virtual void v_EvaluateBoundaryConditions( virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0, const NekDouble time = 0.0,
int var = 0, const std::string varName = "",
std::string varName = "", const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x2_in = NekConstants::kNekUnsetDouble, const NekDouble x3_in = NekConstants::kNekUnsetDouble);
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
virtual map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo(); virtual map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo();
}; };
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
SpatialDomains::BoundaryConditions bcs(m_session, graph3D); SpatialDomains::BoundaryConditions bcs(m_session, graph3D);
GenerateBoundaryConditionExpansion(graph3D,bcs,variable); GenerateBoundaryConditionExpansion(graph3D,bcs,variable);
EvaluateBoundaryConditions(); EvaluateBoundaryConditions(0.0, variable);
ApplyGeomInfo(); ApplyGeomInfo();
// Find periodic edges for this variable. // Find periodic edges for this variable.
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
SpatialDomains::BoundaryConditions bcs(m_session, graph3D); SpatialDomains::BoundaryConditions bcs(m_session, graph3D);
GenerateBoundaryConditionExpansion(graph3D,bcs,variable); GenerateBoundaryConditionExpansion(graph3D,bcs,variable);
EvaluateBoundaryConditions(); EvaluateBoundaryConditions(0.0, variable);
ApplyGeomInfo(); ApplyGeomInfo();
if(!SameTypeOfBoundaryConditions(In)) if(!SameTypeOfBoundaryConditions(In))
...@@ -2393,11 +2393,10 @@ ...@@ -2393,11 +2393,10 @@
* @param bndConditions Information about the boundary conditions. * @param bndConditions Information about the boundary conditions.
*/ */
void DisContField3D::v_EvaluateBoundaryConditions( void DisContField3D::v_EvaluateBoundaryConditions(
const NekDouble time, const NekDouble time,
int var, const std::string varName,
std::string varName, const NekDouble x2_in,
const NekDouble x2_in, const NekDouble x3_in)
const NekDouble x3_in)
{ {
int i; int i;
int npoints; int npoints;
...@@ -2427,38 +2426,7 @@ ...@@ -2427,38 +2426,7 @@
if (filebcs != "") if (filebcs != "")
{ {
cout << "Boundary condition from file:" ExtractFileBCs(filebcs, varName, locExpList);
<< filebcs << endl;
std::vector<LibUtilities::
FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
Import(filebcs, FieldDef, FieldData);
const std::string varNameFld = FieldDef[0]->
m_fields[var];
if (varNameFld == varName)
{
// Copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[var],
locExpList->UpdateCoeffs());
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
else
{
ASSERTL0(
false,
"BCs fields order in session file do not "
"match variable order in the fld file");
}
} }
else else
{ {
......
...@@ -237,11 +237,10 @@ namespace Nektar ...@@ -237,11 +237,10 @@ namespace Nektar
} }
virtual void v_EvaluateBoundaryConditions( virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0, const NekDouble time = 0.0,
int var = 0, const std::string varName = "",
std::string varName = "", const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x2_in = NekConstants::kNekUnsetDouble, const NekDouble x3_in = NekConstants::kNekUnsetDouble);
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
virtual map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo(); virtual map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo();
}; };
......
...@@ -216,13 +216,12 @@ namespace Nektar ...@@ -216,13 +216,12 @@ namespace Nektar
PlanesBndCondExp); PlanesBndCondExp);
} }
} }
EvaluateBoundaryConditions(); EvaluateBoundaryConditions(0.0, variable);
} }
void DisContField3DHomogeneous1D::EvaluateBoundaryConditions( void DisContField3DHomogeneous1D::EvaluateBoundaryConditions(
const NekDouble time, const NekDouble time,
int var, const std::string varName)
std::string varName)
{ {
int n; int n;
const Array<OneD, const NekDouble> z = m_homogeneousBasis->GetZ(); const Array<OneD, const NekDouble> z = m_homogeneousBasis->GetZ();
...@@ -236,7 +235,7 @@ namespace Nektar ...@@ -236,7 +235,7 @@ namespace Nektar
for (n = 0; n < m_planes.num_elements(); ++n) for (n = 0; n < m_planes.num_elements(); ++n)
{ {
m_planes[n]->EvaluateBoundaryConditions( m_planes[n]->EvaluateBoundaryConditions(
time, var, varName, 0.5*m_lhom*(1.0+local_z[n])); time, varName, 0.5*m_lhom*(1.0+local_z[n]));
} }
// Fourier transform coefficient space boundary values // Fourier transform coefficient space boundary values
...@@ -303,13 +302,12 @@ namespace Nektar ...@@ -303,13 +302,12 @@ namespace Nektar
} }
void DisContField3DHomogeneous1D::v_EvaluateBoundaryConditions( void DisContField3DHomogeneous1D::v_EvaluateBoundaryConditions(
const NekDouble time, const NekDouble time,
int var, const std::string varName,
std::string varName, const NekDouble x2_in,
const NekDouble x2_in, const NekDouble x3_in)
const NekDouble x3_in)
{ {
EvaluateBoundaryConditions(time, var, varName); EvaluateBoundaryConditions(time, varName);
} }
boost::shared_ptr<ExpList> &DisContField3DHomogeneous1D:: boost::shared_ptr<ExpList> &DisContField3DHomogeneous1D::
......
...@@ -118,9 +118,8 @@ namespace Nektar ...@@ -118,9 +118,8 @@ namespace Nektar
* evaluated * evaluated
*/ */
MULTI_REGIONS_EXPORT void EvaluateBoundaryConditions( MULTI_REGIONS_EXPORT void EvaluateBoundaryConditions(
const NekDouble time = 0.0, const NekDouble time = 0.0,
int var = 0, const std::string varName = "");
std::string varName = "");
inline const Array<OneD,const MultiRegions::ExpListSharedPtr> inline const Array<OneD,const MultiRegions::ExpListSharedPtr>