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
......@@ -1232,8 +1232,7 @@ namespace Nektar
*/
void DisContField1D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
......
......@@ -224,8 +224,7 @@ 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 std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
......
......@@ -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))
......@@ -2118,8 +2118,7 @@ namespace Nektar
*/
void DisContField2D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
......@@ -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,12 +2172,12 @@ namespace Nektar
condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
}
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
}
else if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eNeumann)
{
......@@ -2232,50 +2187,7 @@ namespace Nektar
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,12 +2198,12 @@ namespace Nektar
m_neumannCondition;
condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
}
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,13 +2222,14 @@ 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());
}
LibUtilities::Equation coeff =
boost::static_pointer_cast<
SpatialDomains::RobinBoundaryCondition>(
m_bndConditions[i])->m_robinPrimitiveCoeff;
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
......@@ -2374,7 +2239,6 @@ namespace Nektar
coeff.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
}
}
else
{
ASSERTL0(false, "This type of BC not implemented yet");
......
......@@ -250,8 +250,7 @@ namespace Nektar
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
......
......@@ -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))
......@@ -2394,8 +2394,7 @@
*/
void DisContField3D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
......@@ -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
{
......
......@@ -238,8 +238,7 @@ namespace Nektar
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
......
......@@ -216,13 +216,12 @@ namespace Nektar
PlanesBndCondExp);
}
}
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
}
void DisContField3DHomogeneous1D::EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName)
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
......@@ -304,12 +303,11 @@ namespace Nektar
void DisContField3DHomogeneous1D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
EvaluateBoundaryConditions(time, var, varName);
EvaluateBoundaryConditions(time, varName);
}
boost::shared_ptr<ExpList> &DisContField3DHomogeneous1D::
......
......@@ -119,8 +119,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();
......@@ -273,8 +272,7 @@ namespace Nektar
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
......
......@@ -177,8 +177,7 @@ namespace Nektar
void DisContField3DHomogeneous2D::EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName)
const std::string varName)
{
int n, m;
const Array<OneD, const NekDouble> y = m_homogeneousBasis_y->GetZ();
......@@ -189,10 +188,7 @@ namespace Nektar
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]));
}
}
......@@ -261,12 +257,11 @@ namespace Nektar
void DisContField3DHomogeneous2D::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
EvaluateBoundaryConditions(time, var, varName);
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();
......@@ -135,8 +134,7 @@ namespace Nektar
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
......
......@@ -1781,6 +1781,44 @@ namespace Nektar
"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;
}
}
}
ASSERTL0(found, "Could not find variable '"+varName+
"' in file boundary condition "+fileName);
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
}
/**
* Given a spectral/hp approximation
......@@ -2503,8 +2541,7 @@ namespace Nektar
*/
void ExpList::v_EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
......
......@@ -706,12 +706,10 @@ namespace Nektar
inline void EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const std::string varName = "",
const NekDouble = NekConstants::kNekUnsetDouble,
const NekDouble = NekConstants::kNekUnsetDouble);
// Routines for continous matrix solution
/// This function calculates the result of the multiplication of a
/// matrix of type specified by \a mkey with a vector given by \a
......@@ -1277,6 +1275,10 @@ namespace Nektar
const Array<OneD, NekDouble> &inarray,
Array<OneD, NekDouble> &outarray);
void ExtractFileBCs(const std::string &fileName,
const std::string &varName,
const boost::shared_ptr<ExpList> locExpList);
// Utility function for a common case of retrieving a
// BoundaryCondition from a boundary condition collection.
MULTI_REGIONS_EXPORT
......@@ -1293,8 +1295,7 @@ namespace Nektar
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
int var = 0,
std::string varName = "",
const std::string varName = "",
const NekDouble x2_in = NekConstants::kNekUnsetDouble,
const NekDouble x3_in = NekConstants::kNekUnsetDouble);
......@@ -2053,12 +2054,11 @@ namespace Nektar
inline void ExpList::EvaluateBoundaryConditions(
const NekDouble time,
int var,
std::string varName,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
v_EvaluateBoundaryConditions(time, var, varName, x2_in, x3_in);
v_EvaluateBoundaryConditions(time, varName, x2_in, x3_in);
}
// Routines for continous matrix solution
......
......@@ -862,8 +862,7 @@ namespace Nektar
for (int i = 0; i < nvariables; ++i)
{
varName = m_session->GetVariable(i);
m_fields[i]->EvaluateBoundaryConditions(
time, i, varName);
m_fields[i]->EvaluateBoundaryConditions(time, varName);
}
}
......
......@@ -217,7 +217,7 @@ namespace Nektar
for (int i = 0; i < nvariables; ++i)
{
varName = m_session->GetVariable(i);
m_fields[i]->EvaluateBoundaryConditions(time, i, varName);
m_fields[i]->EvaluateBoundaryConditions(time, varName);
}
}
......
......@@ -277,7 +277,7 @@ namespace Nektar
for (int i = 0; i < nvariables; ++i)