本文整理汇总了C++中MeshEntity类的典型用法代码示例。如果您正苦于以下问题:C++ MeshEntity类的具体用法?C++ MeshEntity怎么用?C++ MeshEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MeshEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: volume
//-----------------------------------------------------------------------------
double IntervalCell::volume(const MeshEntity& interval) const
{
// Check that we get an interval
if (interval.dim() != 1)
{
dolfin_error("IntervalCell.cpp",
"compute volume (length) of interval cell",
"Illegal mesh entity, not an interval");
}
// Get mesh geometry
const MeshGeometry& geometry = interval.mesh().geometry();
// Get the coordinates of the two vertices
const unsigned int* vertices = interval.entities(0);
const double* x0 = geometry.x(vertices[0]);
const double* x1 = geometry.x(vertices[1]);
// Compute length of interval (line segment)
double sum = 0.0;
for (std::size_t i = 0; i < geometry.dim(); ++i)
{
const double dx = x1[i] - x0[i];
sum += dx*dx;
}
return std::sqrt(sum);
}
示例2: operator
void operator() ( MeshEntity& e ) const
{
if ( M_policy (e.markerID(), M_watermark) )
{
e.replaceFlag ( M_flagPolicy ( e.flag(), M_flagToSet ) );
}
}
示例3: volume
//-----------------------------------------------------------------------------
double QuadrilateralCell::volume(const MeshEntity& cell) const
{
if (cell.dim() != 2)
{
dolfin_error("QuadrilateralCell.cpp",
"compute volume (area) of cell",
"Illegal mesh entity");
}
// Get mesh geometry
const MeshGeometry& geometry = cell.mesh().geometry();
// Get the coordinates of the four vertices
const unsigned int* vertices = cell.entities(0);
const Point p0 = geometry.point(vertices[0]);
const Point p1 = geometry.point(vertices[1]);
const Point p2 = geometry.point(vertices[2]);
const Point p3 = geometry.point(vertices[3]);
if (geometry.dim() == 2)
{
const Point c = (p0 - p2).cross(p1 - p3);
return 0.5 * c.norm();
}
else
dolfin_error("QuadrilateralCell.cpp",
"compute volume of quadrilateral",
"Only know how to compute volume in R^2");
// FIXME: could work in R^3 but need to check co-planarity
return 0.0;
}
示例4: volume
//-----------------------------------------------------------------------------
double HexahedronCell::volume(const MeshEntity& cell) const
{
if (cell.dim() != 2)
{
dolfin_error("HexahedronCell.cpp",
"compute volume (area) of cell",
"Illegal mesh entity");
}
// Get mesh geometry
const MeshGeometry& geometry = cell.mesh().geometry();
// Get the coordinates of the four vertices
const unsigned int* vertices = cell.entities(0);
const Point p0 = geometry.point(vertices[0]);
const Point p1 = geometry.point(vertices[1]);
const Point p2 = geometry.point(vertices[2]);
const Point p3 = geometry.point(vertices[3]);
const Point p4 = geometry.point(vertices[4]);
const Point p5 = geometry.point(vertices[5]);
dolfin_error("HexahedronCell.cpp",
"compute volume of hexahedron",
"Not implemented");
return 0.0;
}
示例5: mvc
//-----------------------------------------------------------------------------
void MeshPartitioning::build_mesh_domains(Mesh& mesh,
const LocalMeshData& local_data)
{
// Local domain data
const std::map<std::size_t, std::vector<
std::pair<std::pair<std::size_t, std::size_t>, std::size_t> > >&
domain_data = local_data.domain_data;
if (domain_data.empty())
return;
// Initialse mesh domains
const std::size_t D = mesh.topology().dim();
mesh.domains().init(D);
std::map<std::size_t, std::vector<
std::pair<std::pair<std::size_t, std::size_t>,
std::size_t> > >::const_iterator dim_data;
for (dim_data = domain_data.begin(); dim_data != domain_data.end();
++dim_data)
{
// Get mesh value collection used for marking
const std::size_t dim = dim_data->first;
// Initialise mesh
mesh.init(dim);
// Create empty MeshValueCollection
MeshValueCollection<std::size_t> mvc(mesh, dim);
// Get domain data
const std::vector<std::pair<std::pair<std::size_t, std::size_t>,
std::size_t> >& local_value_data
= dim_data->second;
// Build mesh value vollection
build_mesh_value_collection(mesh, local_value_data, mvc);
// Get data from mesh value collection
const std::map<std::pair<std::size_t, std::size_t>, std::size_t>& values
= mvc.values();
// Get map from mes domains
std::map<std::size_t, std::size_t>& markers = mesh.domains().markers(dim);
std::map<std::pair<std::size_t, std::size_t>,
std::size_t>::const_iterator it;
for (it = values.begin(); it != values.end(); ++it)
{
const std::size_t cell_index = it->first.first;
const std::size_t local_entity_index = it->first.second;
const Cell cell(mesh, cell_index);
const MeshEntity e(mesh, dim, cell.entities(dim)[local_entity_index]);
markers[e.index()] = it->second;
}
}
}
示例6: end
const_iterator end(const MeshEntity& e) const
{
assert(e.getDimension() <= dimension);
assert(e.getDimension() < dimension || e.getIndex() == 0);
const typename std::map<MeshEntity, qpoints_t>::const_iterator qIter = quadratureMap.find(e);
assert(qIter != quadratureMap.end());
return qIter->second.end();
}
示例7: setQuadrature
void setQuadrature(const MeshEntity& e, const std::map<vertex<dimension>, double> weights)
{
assert(e.getDimension() <= dimension);
// We only have one cell per cell, so if we have quadrature for MeshEntity(dimension, k)
// for k>0, something is wrong
assert(e.getDimension() < dimension || e.getIndex() == 0);
quadratureMap[e] = qpoints_t(weights.begin(), weights.end());
}
示例8: collides_interval_point
//-----------------------------------------------------------------------------
bool CollisionDetection::collides_interval_point(const MeshEntity& entity,
const Point& point)
{
// Get coordinates
const MeshGeometry& geometry = entity.mesh().geometry();
const unsigned int* vertices = entity.entities(0);
return collides_interval_point(geometry.point(vertices[0]),
geometry.point(vertices[1]),
point);
}
示例9: collides
//-----------------------------------------------------------------------------
// High-level collision detection predicates
//-----------------------------------------------------------------------------
bool CollisionPredicates::collides(const MeshEntity& entity,
const Point& point)
{
// Intersection is only implemented for simplex meshes
if (!entity.mesh().type().is_simplex())
{
dolfin_error("Cell.cpp",
"intersect cell and point",
"Intersection is only implemented for simplex meshes");
}
// Get data
const MeshGeometry& g = entity.mesh().geometry();
const unsigned int* v = entity.entities(0);
const std::size_t tdim = entity.mesh().topology().dim();
const std::size_t gdim = entity.mesh().geometry().dim();
// Pick correct specialized implementation
if (tdim == 1 && gdim == 1)
return collides_segment_point_1d(g.point(v[0])[0], g.point(v[1])[0], point[0]);
if (tdim == 1 && gdim == 2)
return collides_segment_point_2d(g.point(v[0]), g.point(v[1]), point);
if (tdim == 1 && gdim == 3)
return collides_segment_point_3d(g.point(v[0]), g.point(v[1]), point);
if (tdim == 2 && gdim == 2)
return collides_triangle_point_2d(g.point(v[0]),
g.point(v[1]),
g.point(v[2]),
point);
if (tdim == 2 && gdim == 3)
return collides_triangle_point_3d(g.point(v[0]),
g.point(v[1]),
g.point(v[2]),
point);
if (tdim == 3)
return collides_tetrahedron_point_3d(g.point(v[0]),
g.point(v[1]),
g.point(v[2]),
g.point(v[3]),
point);
dolfin_error("CollisionPredicates.cpp",
"compute entity-point collision",
"Not implemented for dimensions %d / %d", tdim, gdim);
return false;
}
示例10: GetTextureManager
bool CParaWorldAsset::UnloadAssetByKeyName(const string& keyname)
{
string sFileExt = CParaFile::GetFileExtension(keyname);
if(sFileExt == "dds" || sFileExt == "png")
{
TextureEntity* pEntity = (TextureEntity*) GetTextureManager().get(keyname);
if(pEntity && (pEntity->GetState()==AssetEntity::ASSET_STATE_FAILED_TO_LOAD || pEntity->IsLoaded()))
{
pEntity->UnloadAsset();
pEntity->SetLocalFileName("");
if(pEntity->GetState()==AssetEntity::ASSET_STATE_FAILED_TO_LOAD)
pEntity->SetState(AssetEntity::ASSET_STATE_NORMAL);
return true;
}
}
else if(sFileExt == "x" || sFileExt == "xml")
{
{
MeshEntity* pEntity = (MeshEntity*) GetMeshManager().get(keyname);
if(pEntity && pEntity->IsLoaded())
{
pEntity->UnloadAsset();
pEntity->SetLocalFileName("");
return true;
}
}
{
ParaXEntity* pEntity = (ParaXEntity*) GetParaXManager().get(keyname);
if(pEntity && pEntity->IsLoaded())
{
pEntity->UnloadAsset();
pEntity->SetLocalFileName("");
return true;
}
}
}
#ifdef USE_DIRECTX_RENDERER
else if(sFileExt == "iges")
{
CadModel* pCadModel = (CadModel*) m_CadModelManager.get(keyname);
if(pCadModel && pCadModel->IsLoaded())
{
pCadModel->UnloadAsset();
pCadModel->SetLocalFileName("");
return true;
}
}
#endif
return false;
}
示例11: DoAssetSearch
//--------------------------------------------------------------------
// Desc: Load new template into memory, template with the same identifier
// will not be created twice.
//
// Params: sMeshFileName the identifier string
//--------------------------------------------------------------------
MeshEntity* CParaWorldAsset::LoadMesh(const string& sIdentifier, const string& fileName)
{
string sFileName;
CParaFile::ToCanonicalFilePath(sFileName, fileName, false);
if (m_bUseAssetSearch)
DoAssetSearch(sFileName, CParaFile::GetCurDirectory(CParaFile::APP_MODEL_DIR).c_str());
pair<MeshEntity*, bool> res = GetMeshManager().CreateEntity(sIdentifier, sFileName);
if (res.second == true)
{
MeshEntity* pNewEntity = res.first;
pNewEntity->Init();
}
return res.first;
}
示例12: volume
//-----------------------------------------------------------------------------
double TriangleCell::volume(const MeshEntity& triangle) const
{
// Check that we get a triangle
if (triangle.dim() != 2)
{
dolfin_error("TriangleCell.cpp",
"compute volume (area) of triangle cell",
"Illegal mesh entity, not a triangle");
}
// Get mesh geometry
const MeshGeometry& geometry = triangle.mesh().geometry();
// Get the coordinates of the three vertices
const unsigned int* vertices = triangle.entities(0);
const double* x0 = geometry.x(vertices[0]);
const double* x1 = geometry.x(vertices[1]);
const double* x2 = geometry.x(vertices[2]);
if (geometry.dim() == 2)
{
// Compute area of triangle embedded in R^2
double v2 = (x0[0]*x1[1] + x0[1]*x2[0] + x1[0]*x2[1])
- (x2[0]*x1[1] + x2[1]*x0[0] + x1[0]*x0[1]);
// Formula for volume from http://mathworld.wolfram.com
return 0.5 * std::abs(v2);
}
else if (geometry.dim() == 3)
{
// Compute area of triangle embedded in R^3
const double v0 = (x0[1]*x1[2] + x0[2]*x2[1] + x1[1]*x2[2])
- (x2[1]*x1[2] + x2[2]*x0[1] + x1[1]*x0[2]);
const double v1 = (x0[2]*x1[0] + x0[0]*x2[2] + x1[2]*x2[0])
- (x2[2]*x1[0] + x2[0]*x0[2] + x1[2]*x0[0]);
const double v2 = (x0[0]*x1[1] + x0[1]*x2[0] + x1[0]*x2[1])
- (x2[0]*x1[1] + x2[1]*x0[0] + x1[0]*x0[1]);
// Formula for volume from http://mathworld.wolfram.com
return 0.5*sqrt(v0*v0 + v1*v1 + v2*v2);
}
else
{
dolfin_error("TriangleCell.cpp",
"compute volume of triangle",
"Only know how to compute volume when embedded in R^2 or R^3");
}
return 0.0;
}
示例13: collides_tetrahedron_point
//-----------------------------------------------------------------------------
bool
CollisionDetection::collides_tetrahedron_point(const MeshEntity& tetrahedron,
const Point& point)
{
dolfin_assert(tetrahedron.mesh().topology().dim() == 3);
// Get the vertices as points
const MeshGeometry& geometry = tetrahedron.mesh().geometry();
const unsigned int* vertices = tetrahedron.entities(0);
return collides_tetrahedron_point(geometry.point(vertices[0]),
geometry.point(vertices[1]),
geometry.point(vertices[2]),
geometry.point(vertices[3]),
point);
}
示例14:
/**
* Visitor action; invoke MeshEntity::SetScale on a mesh.
*
* @param [in,out] meshEntity The mesh entity.
*
* @return true.
*/
bool
SetScaleDialog::SetScaleVisitor::Execute(MeshEntity& meshEntity) const
{
if (_rowArgs != NULL)
{
meshEntity.SetScale(MeshEntity::ROW_SLICE_TYPE,
_rowArgs->alignSlice, _rowArgs->refSlice,
_rowArgs->naturalScale, _rowArgs->scaleOrTiles);
}
if (_colArgs != NULL)
{
meshEntity.SetScale(MeshEntity::COL_SLICE_TYPE,
_colArgs->alignSlice, _colArgs->refSlice,
_colArgs->naturalScale, _colArgs->scaleOrTiles);
}
return true;
}
示例15:
/**
* Visitor action; invoke MeshEntity::GeneralFunction on a mesh.
*
* @param [in,out] meshEntity The mesh.
*
* @return true.
*/
bool
GeneralFunctionDialog::GeneralFunctionVisitor::Execute(MeshEntity& meshEntity) const
{
meshEntity.GeneralFunction(_sFactors, _tFactors,
_alignRow, _alignCol, _refRow, _refCol,
_surfaceValues);
return true;
}