Commit 15283a5e authored by Spencer Sherwin's avatar Spencer Sherwin

UPdated C0Project to generate a ContField Expansion and also allow for just...

UPdated C0Project to generate a ContField Expansion and also allow for just projecting a list of specified fields
parent ebb76812
......@@ -126,8 +126,6 @@ namespace Nektar
boost::bind(&ContField2D::GenGlobalLinSys, this, _1),
std::string("GlobalLinSys"))
{
SpatialDomains::BoundaryConditions bcs(m_session, graph2D);
m_locToGloMap = MemoryManager<AssemblyMapCG2D>
::AllocateSharedPtr(m_session,m_ncoeffs,*this,
m_bndCondExpansions,
......@@ -174,7 +172,6 @@ namespace Nektar
boost::bind(&ContField2D::GenGlobalLinSys, this, _1),
std::string("GlobalLinSys"))
{
SpatialDomains::BoundaryConditions bcs(m_session, graph2D);
if(!SameTypeOfBoundaryConditions(In) || CheckIfSingularSystem)
{
m_locToGloMap = MemoryManager<AssemblyMapCG2D>
......
......@@ -64,7 +64,7 @@ namespace Nektar
MULTI_REGIONS_EXPORT ContField2D(
const LibUtilities::SessionReaderSharedPtr &pSession,
const SpatialDomains::MeshGraphSharedPtr &graph2D,
const std::string &variable,
const std::string &variable = "DefaultVar",
const bool DeclareCoeffPhysArrays = true,
const bool CheckIfSingularSystem = false);
......
......@@ -83,8 +83,6 @@ namespace Nektar
boost::bind(&ContField3D::GenGlobalLinSys, this, _1),
std::string("GlobalLinSys"))
{
SpatialDomains::BoundaryConditions bcs(m_session, graph3D);
m_locToGloMap = MemoryManager<AssemblyMapCG3D>::AllocateSharedPtr(
m_session,m_ncoeffs,*this,m_bndCondExpansions,m_bndConditions,
m_periodicVerts, m_periodicEdges, m_periodicFaces,
......
......@@ -57,7 +57,7 @@ namespace Nektar
MULTI_REGIONS_EXPORT ContField3D(
const LibUtilities::SessionReaderSharedPtr &pSession,
const SpatialDomains::MeshGraphSharedPtr &graph3D,
const std::string &variable,
const std::string &variable = "DefaultVar",
const bool CheckIfSingularSystem = false);
/// Construct a global continuous field with solution type based on
......
......@@ -95,20 +95,21 @@ namespace Nektar
m_periodicFwdCopy(),
m_periodicBwdCopy()
{
SpatialDomains::BoundaryConditions bcs(m_session, graph2D);
GenerateBoundaryConditionExpansion(graph2D,bcs,variable,
DeclareCoeffPhysArrays);
if (DeclareCoeffPhysArrays)
if(variable.compare("DefaultVar") != 0) // do not set up BCs if default variable
{
EvaluateBoundaryConditions();
}
SpatialDomains::BoundaryConditions bcs(m_session, graph2D);
GenerateBoundaryConditionExpansion(graph2D,bcs,variable,
DeclareCoeffPhysArrays);
if (DeclareCoeffPhysArrays)
{
EvaluateBoundaryConditions();
}
ApplyGeomInfo();
// Find periodic edges for this variable.
FindPeriodicEdges(bcs, variable);
// Find periodic edges for this variable.
FindPeriodicEdges(bcs, variable);
}
if (SetUpJustDG)
{
......
......@@ -81,18 +81,21 @@
m_bndConditions (),
m_trace(NullExpListSharedPtr)
{
SpatialDomains::BoundaryConditions bcs(m_session, graph3D);
GenerateBoundaryConditionExpansion(graph3D,bcs,variable);
EvaluateBoundaryConditions();
ApplyGeomInfo();
// Find periodic edges for this variable.
FindPeriodicFaces(bcs, variable);
if(variable.compare("DefaultVar") != 0) // do not set up BCs if default variable
{
if(SetUpJustDG)
{
SetUpDG();
SpatialDomains::BoundaryConditions bcs(m_session, graph3D);
GenerateBoundaryConditionExpansion(graph3D,bcs,variable);
EvaluateBoundaryConditions();
// Find periodic edges for this variable.
FindPeriodicFaces(bcs, variable);
}
if(SetUpJustDG)
{
SetUpDG();
}
else
{
......
......@@ -85,7 +85,8 @@ namespace Nektar
bool m_fldToBnd;
MultiRegions::ExpListSharedPtr AppendExpList(string var = "DefaultVar")
MultiRegions::ExpListSharedPtr AppendExpList(string var = "DefaultVar",
bool NewField = false)
{
MultiRegions::ExpListSharedPtr tmp;
switch (m_graph->GetMeshDimension())
......@@ -220,21 +221,38 @@ namespace Nektar
{
if(m_declareExpansionAsContField)
{
MultiRegions::ContField2DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
ContField2D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::ContField2D>::
AllocateSharedPtr(*tmp2,m_graph,var);
if(NewField)
{
tmp = MemoryManager<MultiRegions::ContField2D>::
AllocateSharedPtr(m_session,m_graph,var);
}
else // call copy constructor
{
MultiRegions::ContField2DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
ContField2D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::ContField2D>::
AllocateSharedPtr(*tmp2,m_graph,var);
}
}
else if(m_declareExpansionAsDisContField)
{
MultiRegions::DisContField2DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
DisContField2D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::DisContField2D>::
AllocateSharedPtr(*tmp2,m_graph,var);
if(NewField)
{
tmp = MemoryManager<MultiRegions::DisContField2D>::
AllocateSharedPtr(m_session,m_graph,var);
}
else // call copy constructor
{
MultiRegions::DisContField2DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
DisContField2D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::DisContField2D>::
AllocateSharedPtr(*tmp2,m_graph,var);
}
}
else
{
......@@ -252,21 +270,37 @@ namespace Nektar
{
if(m_declareExpansionAsContField)
{
MultiRegions::ContField3DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
ContField3D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::ContField3D>::
AllocateSharedPtr(*tmp2,m_graph,var);
if(NewField)
{
tmp = MemoryManager<MultiRegions::ContField3D>::
AllocateSharedPtr(m_session,m_graph,var);
}
else
{
MultiRegions::ContField3DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
ContField3D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::ContField3D>::
AllocateSharedPtr(*tmp2,m_graph,var);
}
}
else if(m_declareExpansionAsDisContField)
{
MultiRegions::DisContField3DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
DisContField3D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::DisContField3D>::
AllocateSharedPtr(*tmp2,m_graph,var);
if(NewField)
{
tmp = MemoryManager<MultiRegions::DisContField3D>::
AllocateSharedPtr(m_session,m_graph,var);
}
else
{
MultiRegions::DisContField3DSharedPtr tmp2 =
boost::dynamic_pointer_cast<MultiRegions::
DisContField3D>(m_exp[0]);
tmp = MemoryManager<MultiRegions::DisContField3D>::
AllocateSharedPtr(*tmp2,m_graph,var);
}
}
else
{
......
......@@ -53,7 +53,7 @@ namespace Nektar
ProcessC0Projection::ProcessC0Projection(FieldSharedPtr f) : ProcessModule(f)
{
//f->m_declareExpansionAsContField = true;
m_config["fields"] = ConfigOption(false,"All","Start field to project");
}
ProcessC0Projection::~ProcessC0Projection()
......@@ -62,26 +62,64 @@ namespace Nektar
void ProcessC0Projection::Process(po::variables_map &vm)
{
// generate an C0 expansion field with no boundary conditions.
bool savedef = m_f->m_declareExpansionAsContField;
m_f->m_declareExpansionAsContField = true;
m_c0ProjectExp = m_f->AppendExpList("DefaultVar",true);
m_f->m_declareExpansionAsContField = savedef;
if (m_f->m_verbose)
{
cout << "ProcessC0Projection: Projects fiels into C0 space..." << endl;
}
int i;
int nfields = m_f->m_fielddef[0]->m_fields.size();
for (i = 0; i < nfields; ++i)
{
m_f->m_exp[i]->BwdTrans(m_f->m_exp[i]->GetCoeffs(),
m_f->m_exp[i]->UpdatePhys());
}
for (i = 0; i < nfields; ++i)
{
m_f->m_exp[i]->FwdTrans(m_f->m_exp[i]->GetPhys(),
m_f->m_exp[i]->UpdateCoeffs());
}
int nfields = m_f->m_exp.size();
string fields = m_config["fields"].as<string>();
vector<unsigned int> processFields;
if(fields.compare("All") == 0)
{
for(int i = 0; i < nfields; ++i)
{
processFields.push_back(i);
}
}
else
{
ASSERTL0(ParseUtils::GenerateOrderedVector(fields.c_str(),
processFields),
"Failed to interpret field string in C0Projection");
}
for (int i = 0; i < processFields.size(); ++i)
{
ASSERTL0(processFields[i] < nfields,"Attempt to process field that is larger than then number of fields available");
if (m_f->m_verbose)
{
cout << "\t Processing field: " << processFields[i] << endl;
}
m_c0ProjectExp->BwdTrans(m_f->m_exp[processFields[i]]->GetCoeffs(),
m_f->m_exp[processFields[i]]->UpdatePhys());
m_c0ProjectExp->FwdTrans(m_f->m_exp[processFields[i]]->GetPhys(),
m_f->m_exp[processFields[i]]->UpdateCoeffs());
}
// reset up FieldData with new values before projecting
std::vector<std::vector<NekDouble> > FieldData(m_f->m_fielddef.size());
for(int i = 0; i < nfields; ++i)
{
for (int j = 0; j < m_f->m_fielddef.size(); ++j)
{
m_f->m_exp[i]->AppendFieldData(m_f->m_fielddef[j], FieldData[j]);
}
}
m_f->m_data = FieldData;
}
}
}
}
......@@ -50,7 +50,8 @@ namespace Nektar
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(FieldSharedPtr f) {
static boost::shared_ptr<Module> create(FieldSharedPtr f)
{
return MemoryManager<ProcessC0Projection>::AllocateSharedPtr(f);
}
static ModuleKey className;
......@@ -60,6 +61,10 @@ namespace Nektar
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
private:
MultiRegions::ExpListSharedPtr m_c0ProjectExp;
};
}
}
......
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