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 "Deform a mesh given an input field defining displacement");
106 ConfigOption(
false,
"",
"Name of file containing high order boundary");
109 true,
"0",
"Use vertex IDs instead of face IDs for matching");
120 "ProcessDisplacement needs bnd parameter with a single id.");
122 string toFile =
m_config[
"to"].as<
string>();
126 cout <<
"ProcessDisplacement: you must provide a file" << endl;
130 bool useVertexIds =
m_config[
"usevertexids"].as<
bool>();
132 vector<string> files;
133 files.push_back(toFile);
140 int bndCondId =
m_config[
"bnd"].as<
int>();
144 if (bndGraph->GetMeshDimension() == 1)
146 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
147 m_f->m_variables.push_back(
"v");
150 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
152 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
154 map<int, int> bndCondIds;
155 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
157 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
162 for (
auto &sIt : tmp)
164 auto mIt = bndCondIds.find(sIt.first);
166 if (mIt == bndCondIds.end())
168 cout <<
"Warning: couldn't find element " << sIt.first << endl;
175 std::dynamic_pointer_cast<SpatialDomains::SegGeom>(
176 bndCondExpU->GetExp(e)->GetGeom());
183 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(), to);
185 const int offset = bndCondExpU->GetPhys_Offset(e);
186 const int nq = toSeg->GetTotPoints();
190 bndCondExpU->GetExp(e)->GetCoords(xC, yC);
191 toSeg->GetCoords(xL, yL);
194 tmp = bndCondExpU->UpdatePhys() + offset, 1);
196 tmp = bndCondExpV->UpdatePhys() + offset, 1);
200 bndCondExpU->FwdTransBndConstrained(bndCondExpU->GetPhys(),
201 bndCondExpU->UpdateCoeffs());
202 bndCondExpV->FwdTransBndConstrained(bndCondExpV->GetPhys(),
203 bndCondExpV->UpdateCoeffs());
205 else if (bndGraph->GetMeshDimension() == 2)
207 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
208 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"w"));
209 m_f->m_variables.push_back(
"v");
210 m_f->m_variables.push_back(
"w");
213 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
215 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
217 m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
219 map<int, int> bndCondIds;
220 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
222 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
229 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
232 std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
233 bndCondExpU->GetExp(i)->GetGeom());
235 TriFaceIDs t(from->GetVid(0), from->GetVid(1), from->GetVid(2));
236 vertexFaceMap[t] = i;
242 for (
auto &sIt : tmp)
248 TriFaceIDs t(sIt.second->GetVid(0), sIt.second->GetVid(1),
249 sIt.second->GetVid(2));
251 auto tIt = vertexFaceMap.find(t);
252 e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
256 auto mIt = bndCondIds.find(sIt.first);
257 e = mIt == bndCondIds.end() ? -1 : mIt->second;
262 cout <<
"Warning: couldn't find element " << sIt.first << endl;
267 std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
268 bndCondExpU->GetExp(e)->GetGeom());
275 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
276 bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(), to);
278 const int offset = bndCondExpU->GetPhys_Offset(e);
279 const int nq = toSeg->GetTotPoints();
284 bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
285 toSeg->GetCoords(xL, yL, zL);
288 tmp = bndCondExpU->UpdatePhys() + offset, 1);
290 tmp = bndCondExpV->UpdatePhys() + offset, 1);
292 tmp = bndCondExpW->UpdatePhys() + offset, 1);
296 bndCondExpU->FwdTransBndConstrained(bndCondExpU->GetPhys(),
297 bndCondExpU->UpdateCoeffs());
298 bndCondExpV->FwdTransBndConstrained(bndCondExpV->GetPhys(),
299 bndCondExpV->UpdateCoeffs());
300 bndCondExpW->FwdTransBndConstrained(bndCondExpW->GetPhys(),
301 bndCondExpW->UpdateCoeffs());
#define ASSERTL0(condition, msg)
bool operator==(const VertexSharedPtr &v1, const VertexSharedPtr &v2)
Define comparison operator for the vertex struct.
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
virtual void v_Process(po::variables_map &vm) override
Write mesh to output file.
virtual ~ProcessDisplacement()
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)
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
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
The above copyright notice and this permission notice shall be included.
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)