Commit 179b733d authored by Dave Moxey's avatar Dave Moxey

Merge branch 'fix/bcs-file' of /opt/gitlab/repositories/nektar

parents 24ef0f48 68ee7aac
......@@ -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;
......@@ -102,9 +102,9 @@ namespace Nektar
m_trace = boost::dynamic_pointer_cast<ExpList>(trace);
m_traceMap = MemoryManager<AssemblyMapDG>::
AllocateSharedPtr(pSession,graph1D,trace,*this,
m_bndCondExpansions,m_bndConditions,periodicVertices,
variable);
AllocateSharedPtr(pSession, graph1D, trace, *this,
m_bndCondExpansions, m_bndConditions,
periodicVertices, variable);
tmpBndSol = Array<OneD,NekDouble>
(m_traceMap->GetNumLocalBndCoeffs());
......@@ -172,7 +172,7 @@ namespace Nektar
i);
//1. c) Evaluate the boundary conditions
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
//ApplyGeomInfo();
//2. Set up trace information
......@@ -1230,9 +1230,11 @@ namespace Nektar
* @param bndCondExpansions List of boundary expansions.
* @param bndConditions Information about the boundary conditions.
*/
void DisContField1D::v_EvaluateBoundaryConditions(const NekDouble time,
const NekDouble x2_in,
const NekDouble x3_in)
void DisContField1D::v_EvaluateBoundaryConditions(
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
int i;
......@@ -1295,7 +1297,7 @@ namespace Nektar
}
else
{
ASSERTL0(false,"This type of BC not implemented yet");
ASSERTL0(false, "This type of BC not implemented yet");
}
}
}
......
......@@ -223,9 +223,10 @@ namespace Nektar
/// Evaluate all boundary conditions at a given time..
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
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))
......@@ -2116,9 +2116,11 @@ namespace Nektar
* boundary conditions unless time == 0.0 which is the
* case when the method is called from the constructor.
*/
void DisContField2D::v_EvaluateBoundaryConditions(const NekDouble time,
const NekDouble x2_in,
const NekDouble x3_in)
void DisContField2D::v_EvaluateBoundaryConditions(
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
int i;
int npoints;
......@@ -2141,7 +2143,7 @@ namespace Nektar
// Homogeneous input case for x2.
if (x2_in == NekConstants::kNekUnsetDouble)
{
locExpList->GetCoords(x0,x1,x2);
locExpList->GetCoords(x0, x1, x2);
}
else
{
......@@ -2152,39 +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;
std::vector<LibUtilities::
FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIO f(m_session->GetComm());
f.Import(filebcs, FieldDef, FieldData);
// copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[0],
locExpList->UpdateCoeffs());
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
......@@ -2196,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)
......@@ -2208,47 +2184,10 @@ namespace Nektar
string filebcs = boost::static_pointer_cast<
SpatialDomains::NeumannBoundaryCondition>(
m_bndConditions[i])->m_filename;
if (filebcs != "")
{
string var = filebcs.substr(
0, filebcs.find_last_of("."));
int len=var.length();
var = var.substr(len-1,len);
cout << "Boundary condition from file: "
<< filebcs << endl;
std::vector<LibUtilities::
FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIO f(m_session->GetComm());
f.Import(filebcs, FieldDef, FieldData);
// copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[0],
locExpList->UpdateCoeffs());
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
/*
Array<OneD, NekDouble> x(locExpList->GetTotPoints(),0.0);
Array<OneD, NekDouble> y(locExpList->GetTotPoints(),0.0);
locExpList->GetCoords(x,y);
for(int i=0; i< locExpList->GetTotPoints(); i++)
{
cout<<i<<" "<<x[i]<<" "<<y[i]<<" "
<<locExpList->GetPhys()[i]<<endl;
}
*/
locExpList->IProductWRTBase(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
......@@ -2259,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)
......@@ -2274,40 +2213,7 @@ namespace Nektar
if (filebcs != "")
{
//Never tested!!!
string var = filebcs.substr(
0, filebcs.find_last_of("."));
int len = var.length();
var = var.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);
// copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[0],
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());
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
......@@ -2316,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,9 +249,10 @@ namespace Nektar
}
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
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))
......@@ -2392,110 +2392,98 @@
* @param bndCondExpansions List of boundary conditions.
* @param bndConditions Information about the boundary conditions.
*/
void DisContField3D::v_EvaluateBoundaryConditions(const NekDouble time,
const NekDouble x2_in,
const NekDouble x3_in)
void DisContField3D::v_EvaluateBoundaryConditions(
const NekDouble time,
const std::string varName,
const NekDouble x2_in,
const NekDouble x3_in)
{
int i;
int npoints;
int nbnd = m_bndCondExpansions.num_elements();
MultiRegions::ExpListSharedPtr locExpList;
for(i = 0; i < nbnd; ++i)
for (i = 0; i < nbnd; ++i)
{
if(time == 0.0 || m_bndConditions[i]->GetUserDefined() ==
SpatialDomains::eTimeDependent)
if (time == 0.0 || m_bndConditions[i]->GetUserDefined() ==
SpatialDomains::eTimeDependent)
{
locExpList = m_bndCondExpansions[i];
npoints = locExpList->GetNpoints();
npoints = locExpList->GetNpoints();
Array<OneD,NekDouble> x0(npoints,0.0);
Array<OneD,NekDouble> x1(npoints,0.0);
Array<OneD,NekDouble> x2(npoints,0.0);
Array<OneD, NekDouble> x0(npoints, 0.0);
Array<OneD, NekDouble> x1(npoints, 0.0);
Array<OneD, NekDouble> x2(npoints, 0.0);
locExpList->GetCoords(x0,x1,x2);
locExpList->GetCoords(x0, x1, x2);
if(m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eDirichlet)
if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eDirichlet)
{
string filebcs = boost::static_pointer_cast<
SpatialDomains::DirichletBoundaryCondition>(
m_bndConditions[i])->m_filename;
if(filebcs != "")
if (filebcs != "")
{
string var = filebcs.substr(
0, filebcs.find_last_of("."));
int len = var.length();
var = var.substr(len-1,len);
cout << "Boundary condition from file:"
<< filebcs << endl;
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
Import(filebcs,FieldDef, FieldData);
// copy FieldData into locExpList
locExpList->ExtractDataToCoeffs(
FieldDef[0], FieldData[0],
FieldDef[0]->m_fields[0], locExpList->UpdateCoeffs());
locExpList->BwdTrans_IterPerExp(
locExpList->GetCoeffs(),
locExpList->UpdatePhys());
locExpList->FwdTrans_BndConstrained(
locExpList->GetPhys(),
locExpList->UpdateCoeffs());
ExtractFileBCs(filebcs, varName, locExpList);
}
else
{
LibUtilities::Equation condition = boost::static_pointer_cast<
SpatialDomains::DirichletBoundaryCondition >(m_bndConditions[i])->m_dirichletCondition;
LibUtilities::Equation condition = boost::static_pointer_cast<SpatialDomains::
DirichletBoundaryCondition >(
m_bndConditions[i])->m_dirichletCondition;
condition.Evaluate(x0,x1,x2,time,locExpList->UpdatePhys());
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)
else if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eNeumann)
{
LibUtilities::Equation condition = boost::static_pointer_cast<
SpatialDomains::NeumannBoundaryCondition
>(m_bndConditions[i])->m_neumannCondition;
LibUtilities::Equation condition = boost::
static_pointer_cast<SpatialDomains::
NeumannBoundaryCondition>(
m_bndConditions[i])->m_neumannCondition;
condition.Evaluate(x0,x1,x2,time,locExpList->UpdatePhys());
condition.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
locExpList->IProductWRTBase(locExpList->GetPhys(),
locExpList->UpdateCoeffs());
}
else if(m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eRobin)
else if (m_bndConditions[i]->GetBoundaryConditionType()
== SpatialDomains::eRobin)
{
LibUtilities::Equation condition = boost::static_pointer_cast<
SpatialDomains::RobinBoundaryCondition
>(m_bndConditions[i])->m_robinFunction;
LibUtilities::Equation condition = boost::
static_pointer_cast<SpatialDomains::
RobinBoundaryCondition>(
m_bndConditions[i])->m_robinFunction;
LibUtilities::Equation coeff =
boost::static_pointer_cast<
SpatialDomains::RobinBoundaryCondition
>(m_bndConditions[i])->m_robinPrimitiveCoeff;
LibUtilities::Equation coeff = boost::
static_pointer_cast<SpatialDomains::
RobinBoundaryCondition>(
m_bndConditions[i])->m_robinPrimitiveCoeff;
condition.Evaluate(x0,x1,x2,time,locExpList->UpdatePhys());
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,
// Put primitive coefficient into the physical
// space storage
coeff.Evaluate(x0, x1, x2, time,
locExpList->UpdatePhys());
}
else
{
ASSERTL0(false,"This type of BC not implemented yet");
ASSERTL0(false, "This type of BC not implemented yet");
}
}
}
......
......@@ -237,9 +237,10 @@ namespace Nektar
}
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
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,11 +216,12 @@ namespace Nektar
PlanesBndCondExp);
}
}
EvaluateBoundaryConditions();
EvaluateBoundaryConditions(0.0, variable);
}
void DisContField3DHomogeneous1D::EvaluateBoundaryConditions(
const NekDouble time)
const NekDouble time,
const std::string varName)
{
int n;
const Array<OneD, const NekDouble> z = m_homogeneousBasis->GetZ();
......@@ -234,7 +235,7 @@ namespace Nektar
for (n = 0; n < m_planes.num_elements(); ++n)
{
m_planes[n]->EvaluateBoundaryConditions(
time,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
......@@ -301,11 +302,12 @@ namespace Nektar
}
void DisContField3DHomogeneous1D::v_EvaluateBoundaryConditions(
const NekDouble time,
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);
EvaluateBoundaryConditions(time, varName);
}
boost::shared_ptr<ExpList> &DisContField3DHomogeneous1D::
......
......@@ -118,7 +118,8 @@ namespace Nektar
* evaluated
*/
MULTI_REGIONS_EXPORT void EvaluateBoundaryConditions(
const NekDouble time = 0.0);
const NekDouble time = 0.0,
const std::string varName = "");
inline const Array<OneD,const MultiRegions::ExpListSharedPtr>
&GetBndCondExpansions();
......@@ -270,9 +271,10 @@ namespace Nektar
const Array<OneD, const NekDouble> &dirForcing);
virtual void v_EvaluateBoundaryConditions(
const NekDouble time = 0.0,
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);
......
......@@ -175,29 +175,33 @@ namespace Nektar
EvaluateBoundaryConditions();
}
void DisContField3DHomogeneous2D::EvaluateBoundaryConditions(const NekDouble time)
void DisContField3DHomogeneous2D::EvaluateBoundaryConditions(
const NekDouble time,
const std::string varName)
{
int n,m;
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 (n = 0; n < m_nz; ++n)
{
for(m = 0; m < m_ny; ++m)
for (m = 0; m < m_ny; ++m)
{
m_lines[m+(n*m_ny)]->EvaluateBoundaryConditions(time,0.5*m_lhom_y*(1.0+y[m]),0.5*m_lhom_z*(1.0+z[n]));
m_lines[m+(n*m_ny)]->EvaluateBoundaryConditions(
time, varName, 0.5*m_lhom_y*(1.0+y[m]),
0.5*m_lhom_z*(1.0+z[n]));
}
}