Skip to content
Snippets Groups Projects
Commit 4245074b authored by Spencer Sherwin's avatar Spencer Sherwin
Browse files

Updated white spaces to be consistent with new inset structure

parent d60b4fd5
No related branches found
No related tags found
No related merge requests found
......@@ -53,277 +53,277 @@ using namespace std;
namespace Nektar
{
namespace Utilities
namespace Utilities
{
struct TriFaceIDs
{
struct TriFaceIDs
{
TriFaceIDs(int a, int b, int c) : a(a), b(b), c(c) {}
int a;
int b;
int c;
};
TriFaceIDs(int a, int b, int c) : a(a), b(b), c(c) {}
int a;
int b;
int c;
};
struct TriFaceHash : std::unary_function<TriFaceIDs, std::size_t>
struct TriFaceHash : std::unary_function<TriFaceIDs, std::size_t>
{
std::size_t operator()(TriFaceIDs const& p) const
{
std::size_t operator()(TriFaceIDs const& p) const
{
std::vector<int> ids(3);
std::vector<int> ids(3);
ids[0] = p.a;
ids[1] = p.b;
ids[2] = p.c;
ids[0] = p.a;
ids[1] = p.b;
ids[2] = p.c;
std::sort(ids.begin(), ids.end());
return boost::hash_range(ids.begin(), ids.end());
}
};
std::sort(ids.begin(), ids.end());
return boost::hash_range(ids.begin(), ids.end());
}
};
bool operator==(TriFaceIDs const &p1, TriFaceIDs const &p2)
{
std::vector<int> ids1(3), ids2(3);
bool operator==(TriFaceIDs const &p1, TriFaceIDs const &p2)
{
std::vector<int> ids1(3), ids2(3);
ids1[0] = p1.a;
ids1[1] = p1.b;
ids1[2] = p1.c;
ids2[0] = p2.a;
ids2[1] = p2.b;
ids2[2] = p2.c;
ids1[0] = p1.a;
ids1[1] = p1.b;
ids1[2] = p1.c;
ids2[0] = p2.a;
ids2[1] = p2.b;
ids2[2] = p2.c;
std::sort(ids1.begin(), ids1.end());
std::sort(ids2.begin(), ids2.end());
std::sort(ids1.begin(), ids1.end());
std::sort(ids2.begin(), ids2.end());
return ids1[0] == ids2[0] &&
ids1[1] == ids2[1] &&
ids1[2] == ids2[2];
}
return ids1[0] == ids2[0] &&
ids1[1] == ids2[1] &&
ids1[2] == ids2[2];
}
typedef boost::unordered_map<TriFaceIDs, int, TriFaceHash> TriFaceMap;
typedef boost::unordered_map<TriFaceIDs, int, TriFaceHash> TriFaceMap;
ModuleKey ProcessDisplacement::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "displacement"), ProcessDisplacement::create,
"Deform a mesh given an input field defining displacement");
ModuleKey ProcessDisplacement::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "displacement"), ProcessDisplacement::create,
"Deform a mesh given an input field defining displacement");
ProcessDisplacement::ProcessDisplacement(FieldSharedPtr f) :
ProcessModule(f)
{
m_config["to"] = ConfigOption(
false, "", "Name of file containing high order boundary");
m_config["id"] = ConfigOption(
false, "", "Boundary ID to calculate displacement for");
m_config["usevertexids"] = ConfigOption(
false, "0", "Use vertex IDs instead of face IDs for matching");
f->m_declareExpansionAsContField = true;
f->m_writeBndFld = true;
f->m_fldToBnd = false;
}
ProcessDisplacement::ProcessDisplacement(FieldSharedPtr f) :
ProcessModule(f)
{
m_config["to"] = ConfigOption(
false, "", "Name of file containing high order boundary");
m_config["id"] = ConfigOption(
false, "", "Boundary ID to calculate displacement for");
m_config["usevertexids"] = ConfigOption(
false, "0", "Use vertex IDs instead of face IDs for matching");
f->m_declareExpansionAsContField = true;
f->m_writeBndFld = true;
f->m_fldToBnd = false;
}
ProcessDisplacement::~ProcessDisplacement()
ProcessDisplacement::~ProcessDisplacement()
{
}
void ProcessDisplacement::Process(po::variables_map &vm)
{
if (m_f->m_verbose)
{
cout << "ProcessDisplacement: Calculating displacement..."
<< endl;
}
void ProcessDisplacement::Process(po::variables_map &vm)
string toFile = m_config["to"].as<string>();
if (toFile == "")
{
if (m_f->m_verbose)
{
cout << "ProcessDisplacement: Calculating displacement..."
<< endl;
}
cout << "ProcessDisplacement: you must provide a file" << endl;
return;
}
string toFile = m_config["to"].as<string>();
bool useVertexIds = m_config["usevertexids"].m_beenSet;
if (toFile == "")
{
cout << "ProcessDisplacement: you must provide a file" << endl;
return;
}
vector<string> files;
files.push_back(toFile);
LibUtilities::SessionReaderSharedPtr bndSession =
LibUtilities::SessionReader::CreateInstance(0, NULL, files);
SpatialDomains::MeshGraphSharedPtr bndGraph =
SpatialDomains::MeshGraph::Read(bndSession);
bool useVertexIds = m_config["usevertexids"].m_beenSet;
// Try to find boundary condition expansion.
int bndCondId = m_config["id"].as<int>();
vector<string> files;
files.push_back(toFile);
LibUtilities::SessionReaderSharedPtr bndSession =
LibUtilities::SessionReader::CreateInstance(0, NULL, files);
SpatialDomains::MeshGraphSharedPtr bndGraph =
SpatialDomains::MeshGraph::Read(bndSession);
// FIXME: We should be storing boundary condition IDs
// somewhere...
m_f->m_bndRegionsToWrite.push_back(bndCondId);
// Try to find boundary condition expansion.
int bndCondId = m_config["id"].as<int>();
if (bndGraph->GetMeshDimension() == 1)
{
m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
// FIXME: We should be storing boundary condition IDs
// somewhere...
m_f->m_bndRegionsToWrite.push_back(bndCondId);
MultiRegions::ExpListSharedPtr bndCondExpU =
m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
MultiRegions::ExpListSharedPtr bndCondExpV =
m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
if (bndGraph->GetMeshDimension() == 1)
map<int, int> bndCondIds;
for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
{
m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
= i;
}
MultiRegions::ExpListSharedPtr bndCondExpU =
m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
MultiRegions::ExpListSharedPtr bndCondExpV =
m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
const SpatialDomains::SegGeomMap &tmp =
bndGraph->GetAllSegGeoms();
SpatialDomains::SegGeomMap::const_iterator sIt;
map<int, int> bndCondIds;
for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
{
bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
= i;
}
const SpatialDomains::SegGeomMap &tmp =
bndGraph->GetAllSegGeoms();
SpatialDomains::SegGeomMap::const_iterator sIt;
for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
{
map<int, int>::iterator mIt = bndCondIds.find(sIt->first);
for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
if (mIt == bndCondIds.end())
{
map<int, int>::iterator mIt = bndCondIds.find(sIt->first);
if (mIt == bndCondIds.end())
{
cout << "Warning: couldn't find element "
<< sIt->first << endl;
continue;
}
int e = mIt->second;
cout << "Warning: couldn't find element "
<< sIt->first << endl;
continue;
}
SpatialDomains::SegGeomSharedPtr from =
boost::dynamic_pointer_cast<SpatialDomains::SegGeom>(
bndCondExpU->GetExp(e)->GetGeom());
int e = mIt->second;
SpatialDomains::SegGeomSharedPtr to = sIt->second;
SpatialDomains::SegGeomSharedPtr from =
boost::dynamic_pointer_cast<SpatialDomains::SegGeom>(
bndCondExpU->GetExp(e)->GetGeom());
// Create temporary SegExp
LocalRegions::SegExpSharedPtr toSeg = MemoryManager<
LocalRegions::SegExp>::AllocateSharedPtr(
bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
to);
SpatialDomains::SegGeomSharedPtr to = sIt->second;
const int offset = bndCondExpU->GetPhys_Offset(e);
const int nq = toSeg->GetTotPoints();
// Create temporary SegExp
LocalRegions::SegExpSharedPtr toSeg = MemoryManager<
LocalRegions::SegExp>::AllocateSharedPtr(
bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
to);
Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
const int offset = bndCondExpU->GetPhys_Offset(e);
const int nq = toSeg->GetTotPoints();
bndCondExpU->GetExp(e)->GetCoords(xC, yC);
toSeg->GetCoords(xL, yL);
Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
Vmath::Vsub(nq, xL, 1, xC, 1,
tmp = bndCondExpU->UpdatePhys() + offset, 1);
Vmath::Vsub(nq, yL, 1, yC, 1,
tmp = bndCondExpV->UpdatePhys() + offset, 1);
}
bndCondExpU->GetExp(e)->GetCoords(xC, yC);
toSeg->GetCoords(xL, yL);
// bndconstrained?
bndCondExpU->FwdTrans_BndConstrained(
bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
bndCondExpV->FwdTrans_BndConstrained(
bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
Vmath::Vsub(nq, xL, 1, xC, 1,
tmp = bndCondExpU->UpdatePhys() + offset, 1);
Vmath::Vsub(nq, yL, 1, yC, 1,
tmp = bndCondExpV->UpdatePhys() + offset, 1);
}
else if (bndGraph->GetMeshDimension() == 2)
// bndconstrained?
bndCondExpU->FwdTrans_BndConstrained(
bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
bndCondExpV->FwdTrans_BndConstrained(
bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
}
else if (bndGraph->GetMeshDimension() == 2)
{
m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
m_f->m_exp.push_back(m_f->AppendExpList(0, "w"));
MultiRegions::ExpListSharedPtr bndCondExpU =
m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
MultiRegions::ExpListSharedPtr bndCondExpV =
m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
MultiRegions::ExpListSharedPtr bndCondExpW =
m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
map<int, int> bndCondIds;
for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
{
m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
m_f->m_exp.push_back(m_f->AppendExpList(0, "w"));
bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
= i;
}
MultiRegions::ExpListSharedPtr bndCondExpU =
m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
MultiRegions::ExpListSharedPtr bndCondExpV =
m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
MultiRegions::ExpListSharedPtr bndCondExpW =
m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
TriFaceMap vertexFaceMap;
map<int, int> bndCondIds;
if (useVertexIds)
{
for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
{
bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
= i;
SpatialDomains::TriGeomSharedPtr from =
boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
bndCondExpU->GetExp(i)->GetGeom());
TriFaceIDs t(from->GetVid(0), from->GetVid(1),
from->GetVid(2));
vertexFaceMap[t] = i;
}
}
const SpatialDomains::TriGeomMap &tmp =
bndGraph->GetAllTriGeoms();
SpatialDomains::TriGeomMap::const_iterator sIt;
TriFaceMap vertexFaceMap;
for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
{
TriFaceMap::iterator tIt;
int e;
if (useVertexIds)
{
for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
{
SpatialDomains::TriGeomSharedPtr from =
boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
bndCondExpU->GetExp(i)->GetGeom());
TriFaceIDs t(from->GetVid(0), from->GetVid(1),
from->GetVid(2));
vertexFaceMap[t] = i;
}
}
TriFaceIDs t(sIt->second->GetVid(0),
sIt->second->GetVid(1),
sIt->second->GetVid(2));
const SpatialDomains::TriGeomMap &tmp =
bndGraph->GetAllTriGeoms();
SpatialDomains::TriGeomMap::const_iterator sIt;
for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
tIt = vertexFaceMap.find(t);
e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
}
else
{
TriFaceMap::iterator tIt;
int e;
if (useVertexIds)
{
TriFaceIDs t(sIt->second->GetVid(0),
sIt->second->GetVid(1),
sIt->second->GetVid(2));
tIt = vertexFaceMap.find(t);
e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
}
else
{
map<int, int>::iterator mIt;
mIt = bndCondIds.find(sIt->first);
e = mIt == bndCondIds.end() ? -1 : mIt->second;
}
if (e == -1)
{
cout << "Warning: couldn't find element "
<< sIt->first << endl;
continue;
}
map<int, int>::iterator mIt;
mIt = bndCondIds.find(sIt->first);
e = mIt == bndCondIds.end() ? -1 : mIt->second;
}
SpatialDomains::TriGeomSharedPtr from =
boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
bndCondExpU->GetExp(e)->GetGeom());
if (e == -1)
{
cout << "Warning: couldn't find element "
<< sIt->first << endl;
continue;
}
SpatialDomains::TriGeomSharedPtr to = sIt->second;
SpatialDomains::TriGeomSharedPtr from =
boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
bndCondExpU->GetExp(e)->GetGeom());
// Create temporary SegExp
LocalRegions::TriExpSharedPtr toSeg = MemoryManager<
LocalRegions::TriExp>::AllocateSharedPtr(
bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(),
to);
SpatialDomains::TriGeomSharedPtr to = sIt->second;
const int offset = bndCondExpU->GetPhys_Offset(e);
const int nq = toSeg->GetTotPoints();
// Create temporary SegExp
LocalRegions::TriExpSharedPtr toSeg = MemoryManager<
LocalRegions::TriExp>::AllocateSharedPtr(
bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(),
to);
Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
Array<OneD, NekDouble> zL(nq), zC(nq);
const int offset = bndCondExpU->GetPhys_Offset(e);
const int nq = toSeg->GetTotPoints();
bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
toSeg->GetCoords(xL, yL, zL);
Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
Array<OneD, NekDouble> zL(nq), zC(nq);
Vmath::Vsub(nq, xL, 1, xC, 1,
tmp = bndCondExpU->UpdatePhys() + offset, 1);
Vmath::Vsub(nq, yL, 1, yC, 1,
tmp = bndCondExpV->UpdatePhys() + offset, 1);
Vmath::Vsub(nq, zL, 1, zC, 1,
tmp = bndCondExpW->UpdatePhys() + offset, 1);
}
bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
toSeg->GetCoords(xL, yL, zL);
// bndconstrained?
bndCondExpU->FwdTrans_BndConstrained(
bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
bndCondExpV->FwdTrans_BndConstrained(
bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
bndCondExpW->FwdTrans_BndConstrained(
bndCondExpW->GetPhys(), bndCondExpW->UpdateCoeffs());
Vmath::Vsub(nq, xL, 1, xC, 1,
tmp = bndCondExpU->UpdatePhys() + offset, 1);
Vmath::Vsub(nq, yL, 1, yC, 1,
tmp = bndCondExpV->UpdatePhys() + offset, 1);
Vmath::Vsub(nq, zL, 1, zC, 1,
tmp = bndCondExpW->UpdatePhys() + offset, 1);
}
// bndconstrained?
bndCondExpU->FwdTrans_BndConstrained(
bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
bndCondExpV->FwdTrans_BndConstrained(
bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
bndCondExpW->FwdTrans_BndConstrained(
bndCondExpW->GetPhys(), bndCondExpW->UpdateCoeffs());
}
}
}
}
......@@ -40,28 +40,28 @@
namespace Nektar
{
namespace Utilities
namespace Utilities
{
/**
* @brief This processing module calculates the Q Criterion and adds it
* as an extra-field to the output file.
*/
class ProcessDisplacement : public ProcessModule
{
/**
* @brief This processing module calculates the Q Criterion and adds it
* as an extra-field to the output file.
*/
class ProcessDisplacement : public ProcessModule
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(FieldSharedPtr f) {
return MemoryManager<ProcessDisplacement>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessDisplacement(FieldSharedPtr f);
virtual ~ProcessDisplacement();
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
};
}
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(FieldSharedPtr f) {
return MemoryManager<ProcessDisplacement>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessDisplacement(FieldSharedPtr f);
virtual ~ProcessDisplacement();
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
};
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment