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
SpatialDomains::BoundaryConditions bcs(m_session, graph1D);
GenerateBoundaryConditionExpansion(graph1D,bcs,variable);
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
ApplyGeomInfo();
map<int,int> periodicVertices;
......@@ -172,7 +172,7 @@ namespace Nektar
i);
//1. c) Evaluate the boundary conditions
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
//ApplyGeomInfo();
//2. Set up trace information
......@@ -1231,11 +1231,10 @@ namespace Nektar
* @param bndConditions Information about the boundary conditions.
*/
void DisContField1D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
int i;
......
......@@ -223,11 +223,10 @@ namespace Nektar
/// Evaluate all boundary conditions at a given time..
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
const NekDouble time = 0.0,
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
/// Solve the Helmholtz equation.
virtual void v_HelmSolve(
......
......@@ -102,7 +102,7 @@ namespace Nektar
if (DeclareCoeffPhysArrays)
{
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
}
ApplyGeomInfo();
......@@ -184,7 +184,7 @@ namespace Nektar
if (DeclareCoeffPhysArrays)
{
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
}
if (!SameTypeOfBoundaryConditions(In))
......@@ -2117,11 +2117,10 @@ namespace Nektar
* case when the method is called from the constructor.
*/
void DisContField2D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
int i;
int npoints;
......@@ -2155,57 +2154,13 @@ namespace Nektar
if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eDirichlet)
{
string filebcs = boost::static_pointer_cast<
SpatialDomains::DirichletBoundaryCondition>(
m_bndConditions[i])->m_filename;
if (filebcs != "")
{
string varString = filebcs.substr(
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");
}
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
......@@ -2217,11 +2172,11 @@ namespace Nektar
condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
else if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eNeumann)
......@@ -2229,53 +2184,10 @@ namespace Nektar
string filebcs = boost::static_pointer_cast<
SpatialDomains::NeumannBoundaryCondition>(
m_bndConditions[i])->m_filename;
if (filebcs != "")
{
string varString = filebcs.substr(
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");
}
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
......@@ -2286,11 +2198,11 @@ namespace Nektar
m_neumannCondition;
condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
else if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eRobin)
......@@ -2301,55 +2213,7 @@ namespace Nektar
if (filebcs != "")
{
// Never tested
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");
}
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
......@@ -2358,22 +2222,22 @@ namespace Nektar
SpatialDomains::RobinBoundaryCondition>
(m_bndConditions[i])->
m_robinFunction;
LibUtilities::Equation coeff =
boost::static_pointer_cast<
SpatialDomains::RobinBoundaryCondition>
(m_bndConditions[i])->
m_robinPrimitiveCoeff;
condition.Evaluate(x0, x1, x2, time,
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
{
......
......@@ -249,11 +249,10 @@ namespace Nektar
}
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
const NekDouble time = 0.0,
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
virtual map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo();
};
......
......@@ -84,7 +84,7 @@
SpatialDomains::BoundaryConditions bcs(m_session, graph3D);
GenerateBoundaryConditionExpansion(graph3D,bcs,variable);
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
ApplyGeomInfo();
// Find periodic edges for this variable.
......@@ -138,7 +138,7 @@
SpatialDomains::BoundaryConditions bcs(m_session, graph3D);
GenerateBoundaryConditionExpansion(graph3D,bcs,variable);
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
ApplyGeomInfo();
if(!SameTypeOfBoundaryConditions(In))
......@@ -2393,11 +2393,10 @@
* @param bndConditions Information about the boundary conditions.
*/
void DisContField3D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
int i;
int npoints;
......@@ -2427,38 +2426,7 @@
if (filebcs != "")
{
cout << "Boundary condition from file:"
<< 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");
}
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
......
......@@ -237,11 +237,10 @@ namespace Nektar
}
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
const NekDouble time = 0.0,
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
virtual map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo();
};
......
......@@ -216,13 +216,12 @@ namespace Nektar
PlanesBndCondExp);
}
}
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
}
void DisContField3DHomogeneous1D::EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName)
const NekDouble time,
const std::string varName)
{
int n;
const Array<OneD, const NekDouble> z = m_homogeneousBasis->GetZ();
......@@ -236,7 +235,7 @@ namespace Nektar
for (n = 0; n < m_planes.num_elements(); ++n)
{
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
......@@ -303,13 +302,12 @@ namespace Nektar
}
void DisContField3DHomogeneous1D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
EvaluateBoundaryConditions(time, var, varName);
EvaluateBoundaryConditions(time, varName);
}
boost::shared_ptr<ExpList> &DisContField3DHomogeneous1D::
......
......@@ -118,9 +118,8 @@ namespace Nektar
* evaluated
*/
MULTI_REGIONS_EXPORT void EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "");
const NekDouble time = 0.0,
const std::string varName = "");
inline const Array<OneD,const MultiRegions::ExpListSharedPtr>
&GetBndCondExpansions();
......@@ -272,11 +271,10 @@ namespace Nektar
const Array<OneD, const NekDouble> &dirForcing);
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
const NekDouble time = 0.0,
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
virtual boost::shared_ptr<ExpList> &v_UpdateBndCondExpansion(int i);
......
......@@ -176,23 +176,19 @@ namespace Nektar
}
void DisContField3DHomogeneous2D::EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName)
const NekDouble time,
const std::string varName)
{
int n, m;
const Array<OneD, const NekDouble> y = m_homogeneousBasis_y->GetZ();
const Array<OneD, const NekDouble> z = m_homogeneousBasis_z->GetZ();
for (n = 0; n < m_nz; ++n)
{
for (m = 0; m < m_ny; ++m)
{
m_lines[m+(n*m_ny)]->EvaluateBoundaryConditions(
time,
var,
varName,
0.5*m_lhom_y*(1.0+y[m]),
time, varName, 0.5*m_lhom_y*(1.0+y[m]),
0.5*m_lhom_z*(1.0+z[n]));
}
}
......@@ -259,15 +255,14 @@ namespace Nektar
}
}
void DisContField3DHomogeneous2D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
EvaluateBoundaryConditions(time, var, varName);
}
void DisContField3DHomogeneous2D::v_EvaluateBoundaryConditions(
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
EvaluateBoundaryConditions(time, varName);
}
const Array<OneD,const boost::shared_ptr<ExpList> > &DisContField3DHomogeneous2D::v_GetBndCondExpansions(void)
{
......
......@@ -83,8 +83,7 @@ namespace Nektar
MULTI_REGIONS_EXPORT void EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "");
const std::string varName = "");
inline const Array<OneD,const MultiRegions::ExpListSharedPtr> &GetBndCondExpansions();
......@@ -133,12 +132,11 @@ namespace Nektar
const StdRegions::VarCoeffMap &varcoeff,
const Array<OneD, const NekDouble> &dirForcing);
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
virtual const Array<OneD,const boost::shared_ptr<ExpList> > &v_GetBndCondExpansions(void);
......
......@@ -1780,7 +1780,45 @@ namespace Nektar
ASSERTL0(false,
"This method is not defined or valid for this class type");
}
void ExpList::ExtractFileBCs(
const std::string &fileName,
const std::string &varName,
const boost::shared_ptr<ExpList> locExpList)
{
string varString = fileName.substr(0, fileName.find_last_of("."));
int j, k, 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(fileName, FieldDef, FieldData);
bool found = false;
for (j = 0; j < FieldDef.size(); ++j)
{
for (k = 0; k < FieldDef[j]->m_fields.size(); ++k)
{
if (FieldDef[j]->m_fields[k] == varName)
{
// Copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[j], FieldData[j],
FieldDef[j]->m_fields[k],
locExpList->UpdateCoeffs());
found = true;
}
}
}