66 std::vector<int> ids(3);
72 std::sort(ids.begin(), ids.end());
79 std::vector<int> ids1(3), ids2(3);
88 std::sort(ids1.begin(), ids1.end());
89 std::sort(ids2.begin(), ids2.end());
91 return ids1[0] == ids2[0] && ids1[1] == ids2[1] && ids1[2] == ids2[2];
94typedef std::unordered_map<TriFaceIDs, int, TriFaceHash>
TriFaceMap;
99 "Deform a mesh given an input field defining displacement");
105 ConfigOption(
false,
"",
"Name of file containing high order boundary");
108 true,
"0",
"Use vertex IDs instead of face IDs for matching");
119 "ProcessDisplacement needs bnd parameter with a single id.");
121 string toFile =
m_config[
"to"].as<
string>();
125 cout <<
"ProcessDisplacement: you must provide a file" << endl;
129 bool useVertexIds =
m_config[
"usevertexids"].as<
bool>();
131 vector<string> files;
132 files.push_back(toFile);
139 int bndCondId =
m_config[
"bnd"].as<
int>();
143 if (bndGraph->GetMeshDimension() == 1)
145 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
146 m_f->m_variables.push_back(
"v");
149 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
151 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
153 map<int, int> bndCondIds;
154 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
156 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
161 for (
auto &sIt : tmp)
163 auto mIt = bndCondIds.find(sIt.first);
165 if (mIt == bndCondIds.end())
167 cout <<
"Warning: couldn't find element " << sIt.first << endl;
174 std::dynamic_pointer_cast<SpatialDomains::SegGeom>(
175 bndCondExpU->GetExp(e)->GetGeom());
182 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(), to);
184 const int offset = bndCondExpU->GetPhys_Offset(e);
185 const int nq = toSeg->GetTotPoints();
189 bndCondExpU->GetExp(e)->GetCoords(xC, yC);
190 toSeg->GetCoords(xL, yL);
193 tmp = bndCondExpU->UpdatePhys() + offset, 1);
195 tmp = bndCondExpV->UpdatePhys() + offset, 1);
199 bndCondExpU->FwdTransBndConstrained(bndCondExpU->GetPhys(),
200 bndCondExpU->UpdateCoeffs());
201 bndCondExpV->FwdTransBndConstrained(bndCondExpV->GetPhys(),
202 bndCondExpV->UpdateCoeffs());
204 else if (bndGraph->GetMeshDimension() == 2)
206 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"v"));
207 m_f->m_exp.push_back(
m_f->AppendExpList(0,
"w"));
208 m_f->m_variables.push_back(
"v");
209 m_f->m_variables.push_back(
"w");
212 m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
214 m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
216 m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
218 map<int, int> bndCondIds;
219 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
221 bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
228 for (
int i = 0; i < bndCondExpU->GetExpSize(); ++i)
231 std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
232 bndCondExpU->GetExp(i)->GetGeom());
234 TriFaceIDs t(from->GetVid(0), from->GetVid(1), from->GetVid(2));
235 vertexFaceMap[t] = i;
241 for (
auto &sIt : tmp)
247 TriFaceIDs t(sIt.second->GetVid(0), sIt.second->GetVid(1),
248 sIt.second->GetVid(2));
250 auto tIt = vertexFaceMap.find(t);
251 e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
255 auto mIt = bndCondIds.find(sIt.first);
256 e = mIt == bndCondIds.end() ? -1 : mIt->second;
261 cout <<
"Warning: couldn't find element " << sIt.first << endl;
266 std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
267 bndCondExpU->GetExp(e)->GetGeom());
274 bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
275 bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(), to);
277 const int offset = bndCondExpU->GetPhys_Offset(e);
278 const int nq = toSeg->GetTotPoints();
283 bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
284 toSeg->GetCoords(xL, yL, zL);
287 tmp = bndCondExpU->UpdatePhys() + offset, 1);
289 tmp = bndCondExpV->UpdatePhys() + offset, 1);
291 tmp = bndCondExpW->UpdatePhys() + offset, 1);
295 bndCondExpU->FwdTransBndConstrained(bndCondExpU->GetPhys(),
296 bndCondExpU->UpdateCoeffs());
297 bndCondExpV->FwdTransBndConstrained(bndCondExpV->GetPhys(),
298 bndCondExpV->UpdateCoeffs());
299 bndCondExpW->FwdTransBndConstrained(bndCondExpW->GetPhys(),
300 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)