63 struct TriFaceHash : std::unary_function<TriFaceIDs, std::size_t>
67 std::vector<int> ids(3);
73 std::sort(ids.begin(), ids.end());
80 std::vector<int> ids1(3), ids2(3);
89 std::sort(ids1.begin(), ids1.end());
90 std::sort(ids2.begin(), ids2.end());
92 return ids1[0] == ids2[0] && ids1[1] == ids2[1] && ids1[2] == ids2[2];
95 typedef std::unordered_map<TriFaceIDs, int, TriFaceHash>
TriFaceMap;
97 ModuleKey ProcessDisplacement::className =
100 ProcessDisplacement::create,
101 "Deform a mesh given an input field defining displacement");
107 ConfigOption(
false,
"",
"Name of file containing high order boundary");
110 true,
"0",
"Use vertex IDs instead of face IDs for matching");
121 "ProcessDisplacement needs bnd parameter with a single id.");
123 string toFile =
m_config[
"to"].as<
string>();
127 cout <<
"ProcessDisplacement: you must provide a file" << endl;
131 bool useVertexIds =
m_config[
"usevertexids"].as<
bool>();
133 vector<string> files;
134 files.push_back(toFile);
141 int bndCondId =
m_config[
"bnd"].as<
int>();
145 if (bndGraph->GetMeshDimension() == 1)
147 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
148 m_f->m_variables.push_back(
"v");
151 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
153 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
155 map<int, int> bndCondIds;
156 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
158 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
163 for (
auto &sIt : tmp)
165 auto mIt = bndCondIds.find(sIt.first);
167 if (mIt == bndCondIds.end())
169 cout <<
"Warning: couldn't find element " << sIt.first << endl;
177 bndCondExpU->GetExp(e)->GetGeom());
184 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(), to);
186 const int offset = bndCondExpU->GetPhys_Offset(e);
187 const int nq = toSeg->GetTotPoints();
191 bndCondExpU->GetExp(e)->GetCoords(xC, yC);
192 toSeg->GetCoords(xL, yL);
195 tmp = bndCondExpU->UpdatePhys() + offset, 1);
197 tmp = bndCondExpV->UpdatePhys() + offset, 1);
201 bndCondExpU->FwdTrans_BndConstrained(bndCondExpU->GetPhys(),
202 bndCondExpU->UpdateCoeffs());
203 bndCondExpV->FwdTrans_BndConstrained(bndCondExpV->GetPhys(),
204 bndCondExpV->UpdateCoeffs());
206 else if (bndGraph->GetMeshDimension() == 2)
208 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
209 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"w"));
210 m_f->m_variables.push_back(
"v");
211 m_f->m_variables.push_back(
"w");
214 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
216 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
218 m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
220 map<int, int> bndCondIds;
221 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
223 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
226 TriFaceMap vertexFaceMap;
230 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
234 bndCondExpU->GetExp(i)->GetGeom());
236 TriFaceIDs t(from->GetVid(0), from->GetVid(1), from->GetVid(2));
237 vertexFaceMap[t] = i;
243 for (
auto &sIt : tmp)
249 TriFaceIDs t(sIt.second->GetVid(0), sIt.second->GetVid(1),
250 sIt.second->GetVid(2));
252 auto tIt = vertexFaceMap.find(t);
253 e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
257 auto mIt = bndCondIds.find(sIt.first);
258 e = mIt == bndCondIds.end() ? -1 : mIt->second;
263 cout <<
"Warning: couldn't find element " << sIt.first << endl;
269 bndCondExpU->GetExp(e)->GetGeom());
276 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
277 bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(), to);
279 const int offset = bndCondExpU->GetPhys_Offset(e);
280 const int nq = toSeg->GetTotPoints();
285 bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
286 toSeg->GetCoords(xL, yL, zL);
289 tmp = bndCondExpU->UpdatePhys() + offset, 1);
291 tmp = bndCondExpV->UpdatePhys() + offset, 1);
293 tmp = bndCondExpW->UpdatePhys() + offset, 1);
297 bndCondExpU->FwdTrans_BndConstrained(bndCondExpU->GetPhys(),
298 bndCondExpU->UpdateCoeffs());
299 bndCondExpV->FwdTrans_BndConstrained(bndCondExpV->GetPhys(),
300 bndCondExpV->UpdateCoeffs());
301 bndCondExpW->FwdTrans_BndConstrained(bndCondExpW->GetPhys(),
302 bndCondExpW->UpdateCoeffs());
virtual void Process(po::variables_map &vm)
Write mesh to output file.
#define ASSERTL0(condition, msg)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::unordered_map< TriFaceIDs, int, TriFaceHash > TriFaceMap
std::map< std::string, ConfigOption > m_config
List of configuration values.
Represents a command-line configuration option.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
TriFaceIDs(int a, int b, int c)
void hash_combine(std::size_t &seed)
virtual ~ProcessDisplacement()
std::shared_ptr< Field > FieldSharedPtr
std::map< int, TriGeomSharedPtr > TriGeomMap
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
std::shared_ptr< TriGeom > TriGeomSharedPtr
std::pair< ModuleType, std::string > ModuleKey
std::size_t operator()(TriFaceIDs const &p) const
std::map< int, SegGeomSharedPtr > SegGeomMap
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
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.
std::shared_ptr< SegExp > SegExpSharedPtr
std::shared_ptr< TriExp > TriExpSharedPtr
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< SegGeom > SegGeomSharedPtr
bool operator==(const VertexSharedPtr &v1, const VertexSharedPtr &v2)
Define comparison operator for the vertex struct.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, DomainRangeShPtr rng=NullDomainRangeShPtr, bool fillGraph=true)
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.