50 #include <boost/unordered_set.hpp>
51 #include <boost/tuple/tuple.hpp>
52 #include <boost/tuple/tuple_comparison.hpp>
66 struct TriFaceHash : std::unary_function<TriFaceIDs, std::size_t>
70 std::vector<int> ids(3);
76 std::sort(ids.begin(), ids.end());
77 return boost::hash_range(ids.begin(), ids.end());
83 std::vector<int> ids1(3), ids2(3);
92 std::sort(ids1.begin(), ids1.end());
93 std::sort(ids2.begin(), ids2.end());
95 return ids1[0] == ids2[0] &&
100 typedef boost::unordered_map<TriFaceIDs, int, TriFaceHash>
TriFaceMap;
102 ModuleKey ProcessDisplacement::className =
105 "Deform a mesh given an input field defining displacement");
111 false,
"",
"Name of file containing high order boundary");
113 false,
"",
"Boundary ID to calculate displacement for");
115 false,
"0",
"Use vertex IDs instead of face IDs for matching");
116 f->m_declareExpansionAsContField =
true;
117 f->m_writeBndFld =
true;
118 f->m_fldToBnd =
false;
129 if(
m_f->m_comm->GetRank() == 0)
131 cout <<
"ProcessDisplacement: Calculating displacement..."
136 string toFile =
m_config[
"to"].as<
string>();
140 cout <<
"ProcessDisplacement: you must provide a file" << endl;
144 bool useVertexIds =
m_config[
"usevertexids"].m_beenSet;
146 vector<string> files;
147 files.push_back(toFile);
154 int bndCondId =
m_config[
"id"].as<
int>();
158 m_f->m_bndRegionsToWrite.push_back(bndCondId);
160 if (bndGraph->GetMeshDimension() == 1)
162 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
165 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
167 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
169 map<int, int> bndCondIds;
170 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
172 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
177 bndGraph->GetAllSegGeoms();
178 SpatialDomains::SegGeomMap::const_iterator sIt;
180 for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
184 if (mIt == bndCondIds.end())
186 cout <<
"Warning: couldn't find element "
187 << sIt->first << endl;
195 bndCondExpU->GetExp(e)->GetGeom());
202 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
205 const int offset = bndCondExpU->GetPhys_Offset(e);
210 bndCondExpU->GetExp(e)->GetCoords(xC, yC);
211 toSeg->GetCoords(xL, yL);
214 tmp = bndCondExpU->UpdatePhys() + offset, 1);
216 tmp = bndCondExpV->UpdatePhys() + offset, 1);
220 bndCondExpU->FwdTrans_BndConstrained(
221 bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
222 bndCondExpV->FwdTrans_BndConstrained(
223 bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
225 else if (bndGraph->GetMeshDimension() == 2)
227 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
228 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"w"));
231 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
233 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
235 m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
237 map<int, int> bndCondIds;
238 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
240 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
244 TriFaceMap vertexFaceMap;
248 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
252 bndCondExpU->GetExp(i)->GetGeom());
254 TriFaceIDs t(from->GetVid(0), from->GetVid(1),
256 vertexFaceMap[t] = i;
261 bndGraph->GetAllTriGeoms();
262 SpatialDomains::TriGeomMap::const_iterator sIt;
264 for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
272 sIt->second->GetVid(1),
273 sIt->second->GetVid(2));
275 tIt = vertexFaceMap.find(t);
276 e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
281 mIt = bndCondIds.find(sIt->first);
282 e = mIt == bndCondIds.end() ? -1 : mIt->second;
287 cout <<
"Warning: couldn't find element "
288 << sIt->first << endl;
294 bndCondExpU->GetExp(e)->GetGeom());
301 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
302 bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(),
305 const int offset = bndCondExpU->GetPhys_Offset(e);
311 bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
312 toSeg->GetCoords(xL, yL, zL);
315 tmp = bndCondExpU->UpdatePhys() + offset, 1);
317 tmp = bndCondExpV->UpdatePhys() + offset, 1);
319 tmp = bndCondExpW->UpdatePhys() + offset, 1);
323 bndCondExpU->FwdTrans_BndConstrained(
324 bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
325 bndCondExpV->FwdTrans_BndConstrained(
326 bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
327 bndCondExpW->FwdTrans_BndConstrained(
328 bndCondExpW->GetPhys(), bndCondExpW->UpdateCoeffs());
pair< ModuleType, string > ModuleKey
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
map< string, ConfigOption > m_config
List of configuration values.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
FieldSharedPtr m_f
Field object.
std::size_t operator()(TriFaceIDs const &p) const
std::map< int, TriGeomSharedPtr > TriGeomMap
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
boost::shared_ptr< SegExp > SegExpSharedPtr
boost::shared_ptr< SegGeom > SegGeomSharedPtr
std::map< int, SegGeomSharedPtr > SegGeomMap
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
boost::shared_ptr< Field > FieldSharedPtr
boost::unordered_map< TriFaceIDs, int, TriFaceHash > TriFaceMap
virtual ~ProcessDisplacement()
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Represents a command-line configuration option.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
TriFaceIDs(int a, int b, int c)
boost::shared_ptr< TriGeom > TriGeomSharedPtr
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
bool operator==(const VertexSharedPtr &v1, const VertexSharedPtr &v2)
Define comparison operator for the vertex struct.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
boost::shared_ptr< TriExp > TriExpSharedPtr
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.