65 std::vector<int> ids(3);
71 std::sort(ids.begin(), ids.end());
78 std::vector<int> ids1(3), ids2(3);
87 std::sort(ids1.begin(), ids1.end());
88 std::sort(ids2.begin(), ids2.end());
90 return ids1[0] == ids2[0] && ids1[1] == ids2[1] && ids1[2] == ids2[2];
93typedef std::unordered_map<TriFaceIDs, int, TriFaceHash>
TriFaceMap;
98 "Deform a mesh given an input field defining displacement");
104 ConfigOption(
false,
"",
"Name of file containing high order boundary");
107 true,
"0",
"Use vertex IDs instead of face IDs for matching");
118 "ProcessDisplacement needs bnd parameter with a single id.");
120 string toFile =
m_config[
"to"].as<
string>();
124 cout <<
"ProcessDisplacement: you must provide a file" << endl;
128 bool useVertexIds =
m_config[
"usevertexids"].as<
bool>();
130 vector<string> files;
131 files.push_back(toFile);
138 int bndCondId =
m_config[
"bnd"].as<
int>();
142 if (bndGraph->GetMeshDimension() == 1)
144 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
145 m_f->m_variables.push_back(
"v");
148 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
150 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
152 map<int, int> bndCondIds;
153 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
155 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
160 for (
auto &sIt : tmp)
162 auto mIt = bndCondIds.find(sIt.first);
164 if (mIt == bndCondIds.end())
166 cout <<
"Warning: couldn't find element " << sIt.first << endl;
173 std::dynamic_pointer_cast<SpatialDomains::SegGeom>(
174 bndCondExpU->GetExp(e)->GetGeom());
181 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(), to);
183 const int offset = bndCondExpU->GetPhys_Offset(e);
184 const int nq = toSeg->GetTotPoints();
188 bndCondExpU->GetExp(e)->GetCoords(xC, yC);
189 toSeg->GetCoords(xL, yL);
192 tmp = bndCondExpU->UpdatePhys() + offset, 1);
194 tmp = bndCondExpV->UpdatePhys() + offset, 1);
198 bndCondExpU->FwdTransBndConstrained(bndCondExpU->GetPhys(),
199 bndCondExpU->UpdateCoeffs());
200 bndCondExpV->FwdTransBndConstrained(bndCondExpV->GetPhys(),
201 bndCondExpV->UpdateCoeffs());
203 else if (bndGraph->GetMeshDimension() == 2)
205 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
206 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"w"));
207 m_f->m_variables.push_back(
"v");
208 m_f->m_variables.push_back(
"w");
211 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
213 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
215 m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
217 map<int, int> bndCondIds;
218 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
220 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
227 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
230 std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
231 bndCondExpU->GetExp(i)->GetGeom());
233 TriFaceIDs t(from->GetVid(0), from->GetVid(1), from->GetVid(2));
234 vertexFaceMap[t] = i;
240 for (
auto &sIt : tmp)
246 TriFaceIDs t(sIt.second->GetVid(0), sIt.second->GetVid(1),
247 sIt.second->GetVid(2));
249 auto tIt = vertexFaceMap.find(t);
250 e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
254 auto mIt = bndCondIds.find(sIt.first);
255 e = mIt == bndCondIds.end() ? -1 : mIt->second;
260 cout <<
"Warning: couldn't find element " << sIt.first << endl;
265 std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
266 bndCondExpU->GetExp(e)->GetGeom());
273 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
274 bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(), to);
276 const int offset = bndCondExpU->GetPhys_Offset(e);
277 const int nq = toSeg->GetTotPoints();
282 bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
283 toSeg->GetCoords(xL, yL, zL);
286 tmp = bndCondExpU->UpdatePhys() + offset, 1);
288 tmp = bndCondExpV->UpdatePhys() + offset, 1);
290 tmp = bndCondExpW->UpdatePhys() + offset, 1);
294 bndCondExpU->FwdTransBndConstrained(bndCondExpU->GetPhys(),
295 bndCondExpU->UpdateCoeffs());
296 bndCondExpV->FwdTransBndConstrained(bndCondExpV->GetPhys(),
297 bndCondExpV->UpdateCoeffs());
298 bndCondExpW->FwdTransBndConstrained(bndCondExpW->GetPhys(),
299 bndCondExpW->UpdateCoeffs());
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
ProcessDisplacement(FieldSharedPtr f)
void v_Process(po::variables_map &vm) override
Write mesh to output file.
static ModuleKey className
~ProcessDisplacement() override
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
bool operator==(TriFaceIDs const &p1, TriFaceIDs const &p2)
std::unordered_map< TriFaceIDs, int, TriFaceHash > TriFaceMap
ModuleFactory & GetModuleFactory()
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< SegExp > SegExpSharedPtr
std::shared_ptr< TriExp > TriExpSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::map< int, TriGeomSharedPtr > TriGeomMap
std::map< int, SegGeomSharedPtr > SegGeomMap
std::shared_ptr< SegGeom > SegGeomSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< TriGeom > TriGeomSharedPtr
void hash_combine(std::size_t &seed)
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.
std::size_t operator()(TriFaceIDs const &p) const
TriFaceIDs(int a, int b, int c)