本文整理汇总了C++中meshlib::Mesh::getDimension方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::getDimension方法的具体用法?C++ Mesh::getDimension怎么用?C++ Mesh::getDimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meshlib::Mesh
的用法示例。
在下文中一共展示了Mesh::getDimension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeConcreteProcess
void RichardsComponentTransportProcess::initializeConcreteProcess(
NumLib::LocalToGlobalIndexMap const& dof_table,
MeshLib::Mesh const& mesh,
unsigned const integration_order)
{
const int monolithic_process_id = 0;
ProcessLib::ProcessVariable const& pv =
getProcessVariables(monolithic_process_id)[0];
ProcessLib::createLocalAssemblers<LocalAssemblerData>(
mesh.getDimension(), mesh.getElements(), dof_table,
pv.getShapeFunctionOrder(), _local_assemblers,
mesh.isAxiallySymmetric(), integration_order, _process_data);
_secondary_variables.addSecondaryVariable(
"darcy_velocity",
makeExtrapolator(mesh.getDimension(), getExtrapolator(),
_local_assemblers,
&RichardsComponentTransportLocalAssemblerInterface::
getIntPtDarcyVelocity));
_secondary_variables.addSecondaryVariable(
"saturation",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&RichardsComponentTransportLocalAssemblerInterface::
getIntPtSaturation));
}
示例2: initializeConcreteProcess
void HTProcess::initializeConcreteProcess(
NumLib::LocalToGlobalIndexMap const& dof_table,
MeshLib::Mesh const& mesh,
unsigned const integration_order)
{
// For the staggered scheme, both processes are assumed to use the same
// element order. Therefore the order of shape function can be fetched from
// any set of the sets of process variables of the coupled processes. Here,
// we take the one from the first process by setting process_id = 0.
const int process_id = 0;
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
if (_use_monolithic_scheme)
{
ProcessLib::createLocalAssemblers<MonolithicHTFEM>(
mesh.getDimension(), mesh.getElements(), dof_table,
pv.getShapeFunctionOrder(), _local_assemblers,
mesh.isAxiallySymmetric(), integration_order,
*_material_properties);
}
else
{
ProcessLib::createLocalAssemblers<StaggeredHTFEM>(
mesh.getDimension(), mesh.getElements(), dof_table,
pv.getShapeFunctionOrder(), _local_assemblers,
mesh.isAxiallySymmetric(), integration_order, *_material_properties,
_heat_transport_process_id, _hydraulic_process_id);
}
_secondary_variables.addSecondaryVariable(
"darcy_velocity",
makeExtrapolator(mesh.getDimension(), getExtrapolator(),
_local_assemblers,
&HTLocalAssemblerInterface::getIntPtDarcyVelocity));
}
示例3: convertMeshToGeo
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double eps)
{
if (mesh.getDimension() != 2)
{
ERR ("Mesh to geometry conversion is only working for 2D meshes.");
return false;
}
// nodes to points conversion
std::string mesh_name(mesh.getName());
{
auto points = std::make_unique<std::vector<GeoLib::Point*>>();
points->reserve(mesh.getNumberOfNodes());
for (auto node_ptr : mesh.getNodes())
points->push_back(new GeoLib::Point(*node_ptr, node_ptr->getID()));
geo_objects.addPointVec(std::move(points), mesh_name, nullptr, eps);
}
const std::vector<std::size_t> id_map (geo_objects.getPointVecObj(mesh_name)->getIDMap());
// elements to surface triangles conversion
std::string const mat_name ("MaterialIDs");
auto bounds (MeshInformation::getValueBounds<int>(mesh, mat_name));
const unsigned nMatGroups(bounds.second-bounds.first+1);
auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>();
sfcs->reserve(nMatGroups);
auto const& points = *geo_objects.getPointVec(mesh_name);
for (unsigned i=0; i<nMatGroups; ++i)
sfcs->push_back(new GeoLib::Surface(points));
const std::vector<MeshLib::Element*> &elements = mesh.getElements();
const std::size_t nElems (mesh.getNumberOfElements());
MeshLib::PropertyVector<int> const*const materialIds =
mesh.getProperties().existsPropertyVector<int>("MaterialIDs")
? mesh.getProperties().getPropertyVector<int>("MaterialIDs")
: nullptr;
for (unsigned i=0; i<nElems; ++i)
{
auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first);
MeshLib::Element* e (elements[i]);
if (e->getGeomType() == MeshElemType::TRIANGLE)
(*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]);
if (e->getGeomType() == MeshElemType::QUAD)
{
(*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]);
(*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(2)], id_map[e->getNodeIndex(3)]);
}
// all other element types are ignored (i.e. lines)
}
std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc){ if (sfc->getNumberOfTriangles()==0) delete sfc; sfc = nullptr;});
auto sfcs_end = std::remove(sfcs->begin(), sfcs->end(), nullptr);
sfcs->erase(sfcs_end, sfcs->end());
geo_objects.addSurfaceVec(std::move(sfcs), mesh_name);
return true;
}
示例4: initializeConcreteProcess
void HeatTransportBHEProcess::initializeConcreteProcess(
NumLib::LocalToGlobalIndexMap const& dof_table,
MeshLib::Mesh const& mesh,
unsigned const integration_order)
{
// Quick access map to BHE's through element ids.
std::unordered_map<std::size_t, BHE::BHETypes*> element_to_bhe_map;
int const n_BHEs = _process_data._vec_BHE_property.size();
for (int i = 0; i < n_BHEs; i++)
{
auto const& bhe_elements = _bheMeshData.BHE_elements[i];
for (auto const& e : bhe_elements)
{
element_to_bhe_map[e->getID()] =
&_process_data._vec_BHE_property[i];
}
}
assert(mesh.getDimension() == 3);
ProcessLib::HeatTransportBHE::createLocalAssemblers<
HeatTransportBHELocalAssemblerSoil, HeatTransportBHELocalAssemblerBHE>(
mesh.getElements(), dof_table, _local_assemblers, element_to_bhe_map,
mesh.isAxiallySymmetric(), integration_order, _process_data);
// Create BHE boundary conditions for each of the BHEs
createBHEBoundaryConditionTopBottom(_bheMeshData.BHE_nodes);
}
示例5: createPythonBoundaryCondition
std::unique_ptr<PythonBoundaryCondition> createPythonBoundaryCondition(
BaseLib::ConfigTree const& config, MeshLib::Mesh const& boundary_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table, std::size_t bulk_mesh_id,
int const variable_id, int const component_id,
unsigned const integration_order, unsigned const shapefunction_order,
unsigned const global_dim)
{
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type}
config.checkConfigParameter("type", "Python");
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Python__bc_object}
auto const bc_object = config.getConfigParameter<std::string>("bc_object");
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Python__flush_stdout}
auto const flush_stdout = config.getConfigParameter("flush_stdout", false);
// Evaluate Python code in scope of main module
pybind11::object scope =
pybind11::module::import("__main__").attr("__dict__");
if (!scope.contains(bc_object))
OGS_FATAL(
"Function `%s' is not defined in the python script file, or there "
"was no python script file specified.",
bc_object.c_str());
auto* bc = scope[bc_object.c_str()]
.cast<PythonBoundaryConditionPythonSideInterface*>();
if (variable_id >= static_cast<int>(dof_table.getNumberOfVariables()) ||
component_id >= dof_table.getNumberOfVariableComponents(variable_id))
{
OGS_FATAL(
"Variable id or component id too high. Actual values: (%d, %d), "
"maximum values: (%d, %d).",
variable_id, component_id, dof_table.getNumberOfVariables(),
dof_table.getNumberOfVariableComponents(variable_id));
}
// In case of partitioned mesh the boundary could be empty, i.e. there is no
// boundary condition.
#ifdef USE_PETSC
// This can be extracted to createBoundaryCondition() but then the config
// parameters are not read and will cause an error.
// TODO (naumov): Add a function to ConfigTree for skipping the tags of the
// subtree and move the code up in createBoundaryCondition().
if (boundary_mesh.getDimension() == 0 &&
boundary_mesh.getNumberOfNodes() == 0 &&
boundary_mesh.getNumberOfElements() == 0)
{
return nullptr;
}
#endif // USE_PETSC
return std::make_unique<PythonBoundaryCondition>(
PythonBoundaryConditionData{
bc, dof_table, bulk_mesh_id,
dof_table.getGlobalComponent(variable_id, component_id),
boundary_mesh},
integration_order, shapefunction_order, global_dim, flush_stdout);
}
示例6: nElements
std::vector<GeoLib::PointWithID*> MshEditor::getSurfaceNodes(const MeshLib::Mesh &mesh, const double *dir)
{
INFO ("Extracting surface nodes...");
const std::vector<MeshLib::Element*> all_elements (mesh.getElements());
const std::vector<MeshLib::Node*> all_nodes (mesh.getNodes());
std::vector<MeshLib::Element*> sfc_elements;
get2DSurfaceElements(all_elements, sfc_elements, dir, mesh.getDimension());
std::vector<MeshLib::Node*> sfc_nodes;
std::vector<unsigned> node_id_map(mesh.getNNodes());
get2DSurfaceNodes(all_nodes, sfc_nodes, sfc_elements, node_id_map);
const unsigned nElements (sfc_elements.size());
for (unsigned i=0; i<nElements; ++i)
delete sfc_elements[i];
const size_t nNodes (sfc_nodes.size());
std::vector<GeoLib::PointWithID*> surface_pnts(nNodes);
for (unsigned i=0; i<nNodes; ++i)
{
surface_pnts[i] = new GeoLib::PointWithID(sfc_nodes[i]->getCoords(), sfc_nodes[i]->getID());
delete sfc_nodes[i];
}
return surface_pnts;
}
示例7: layerMapping
bool MeshLayerMapper::layerMapping(MeshLib::Mesh &new_mesh, GeoLib::Raster const& raster, double noDataReplacementValue = 0.0)
{
if (new_mesh.getDimension() != 2)
{
ERR("MshLayerMapper::layerMapping() - requires 2D mesh");
return false;
}
GeoLib::RasterHeader const& header (raster.getHeader());
const double x0(header.origin[0]);
const double y0(header.origin[1]);
const double delta(header.cell_size);
const std::pair<double, double> xDim(x0, x0 + header.n_cols * delta); // extension in x-dimension
const std::pair<double, double> yDim(y0, y0 + header.n_rows * delta); // extension in y-dimension
const std::size_t nNodes (new_mesh.getNumberOfNodes());
const std::vector<MeshLib::Node*> &nodes = new_mesh.getNodes();
for (unsigned i = 0; i < nNodes; ++i)
{
if (!raster.isPntOnRaster(*nodes[i]))
{
// use either default value or elevation from layer above
nodes[i]->updateCoordinates((*nodes[i])[0], (*nodes[i])[1], noDataReplacementValue);
continue;
}
double elevation (raster.interpolateValueAtPoint(*nodes[i]));
if (std::abs(elevation - header.no_data) < std::numeric_limits<double>::epsilon())
elevation = noDataReplacementValue;
nodes[i]->updateCoordinates((*nodes[i])[0], (*nodes[i])[1], elevation);
}
return true;
}
示例8: createDirichletBoundaryCondition
std::unique_ptr<DirichletBoundaryCondition> createDirichletBoundaryCondition(
BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
int const component_id,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters)
{
DBUG("Constructing DirichletBoundaryCondition from config.");
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type}
config.checkConfigParameter("type", "Dirichlet");
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__Dirichlet__parameter}
auto const param_name = config.getConfigParameter<std::string>("parameter");
DBUG("Using parameter %s", param_name.c_str());
auto& param = findParameter<double>(param_name, parameters, 1);
// In case of partitioned mesh the boundary could be empty, i.e. there is no
// boundary condition.
#ifdef USE_PETSC
// This can be extracted to createBoundaryCondition() but then the config
// parameters are not read and will cause an error.
// TODO (naumov): Add a function to ConfigTree for skipping the tags of the
// subtree and move the code up in createBoundaryCondition().
if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
bc_mesh.getNumberOfElements() == 0)
{
return nullptr;
}
#endif // USE_PETSC
return std::make_unique<DirichletBoundaryCondition>(
param, bc_mesh, dof_table_bulk, variable_id, component_id);
}
示例9: getSurfaceAreaForNodes
void MeshSurfaceExtraction::getSurfaceAreaForNodes(const MeshLib::Mesh &mesh, std::vector<double> &node_area_vec)
{
if (mesh.getDimension() == 2)
{
double total_area (0);
// for each node, a vector containing all the element idget every element
const std::vector<MeshLib::Node*> &nodes = mesh.getNodes();
const size_t nNodes ( mesh.getNNodes() );
node_area_vec.reserve(nNodes);
for (size_t n=0; n<nNodes; ++n)
{
double node_area (0);
std::vector<MeshLib::Element*> conn_elems = nodes[n]->getElements();
const size_t nConnElems (conn_elems.size());
for (size_t i=0; i<nConnElems; ++i)
{
const MeshLib::Element* elem (conn_elems[i]);
const unsigned nElemParts = (elem->getGeomType() == MeshElemType::TRIANGLE) ? 3 : 4;
const double area = conn_elems[i]->getContent() / nElemParts;
node_area += area;
total_area += area;
}
node_area_vec.push_back(node_area);
}
INFO ("Total surface Area: %f", total_area);
}
else
ERR ("Error in MeshSurfaceExtraction::getSurfaceAreaForNodes() - Given mesh is no surface mesh (dimension != 2).");
}
示例10: SmallDeformationNonlocalProcess
SmallDeformationNonlocalProcess<DisplacementDim>::
SmallDeformationNonlocalProcess(
MeshLib::Mesh& mesh,
std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&&
jacobian_assembler,
std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
parameters,
unsigned const integration_order,
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
process_variables,
SmallDeformationNonlocalProcessData<DisplacementDim>&& process_data,
SecondaryVariableCollection&& secondary_variables,
NumLib::NamedFunctionCaller&& named_function_caller)
: Process(mesh, std::move(jacobian_assembler), parameters,
integration_order, std::move(process_variables),
std::move(secondary_variables), std::move(named_function_caller)),
_process_data(std::move(process_data))
{
_nodal_forces = MeshLib::getOrCreateMeshProperty<double>(
mesh, "NodalForces", MeshLib::MeshItemType::Node, DisplacementDim);
_integration_point_writer.emplace_back(
std::make_unique<SigmaIntegrationPointWriter>(
static_cast<int>(mesh.getDimension() == 2 ? 4 : 6) /*n components*/,
integration_order, [this]() {
// Result containing integration point data for each local
// assembler.
std::vector<std::vector<double>> result;
result.resize(_local_assemblers.size());
for (std::size_t i = 0; i < _local_assemblers.size(); ++i)
{
auto const& local_asm = *_local_assemblers[i];
result[i] = local_asm.getSigma();
}
return result;
}));
_integration_point_writer.emplace_back(
std::make_unique<KappaDIntegrationPointWriter>(
integration_order, [this]() {
// Result containing integration point data for each local
// assembler.
std::vector<std::vector<double>> result;
result.resize(_local_assemblers.size());
for (std::size_t i = 0; i < _local_assemblers.size(); ++i)
{
auto const& local_asm = *_local_assemblers[i];
result[i] = local_asm.getKappaD();
}
return result;
}));
}
示例11: mapToStaticValue
bool MeshLayerMapper::mapToStaticValue(MeshLib::Mesh &mesh, double value)
{
if (mesh.getDimension() != 2)
{
ERR("MshLayerMapper::mapToStaticValue() - requires 2D mesh");
return false;
}
std::vector<MeshLib::Node*> const& nodes (mesh.getNodes());
for (MeshLib::Node* node : nodes)
node->updateCoordinates((*node)[0], (*node)[1], value);
return true;
}
示例12: SourceTerm
VolumetricSourceTerm::VolumetricSourceTerm(
MeshLib::Mesh const& source_term_mesh,
std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
unsigned const integration_order, unsigned const shapefunction_order,
Parameter<double> const& volumetric_source_term)
: SourceTerm(std::move(source_term_dof_table)),
_volumetric_source_term(volumetric_source_term)
{
ProcessLib::createLocalAssemblers<VolumetricSourceTermLocalAssembler>(
source_term_mesh.getDimension(), source_term_mesh.getElements(),
*_source_term_dof_table, shapefunction_order, _local_assemblers,
source_term_mesh.isAxiallySymmetric(), integration_order,
_volumetric_source_term);
}
示例13: createLayers
bool LayeredMeshGenerator::createLayers(MeshLib::Mesh const& mesh,
std::vector<std::string> const& raster_paths,
double minimum_thickness,
double noDataReplacementValue)
{
if (mesh.getDimension() != 2 || !allRastersExist(raster_paths))
return false;
std::vector<GeoLib::Raster const*> rasters;
rasters.reserve(raster_paths.size());
for (auto path = raster_paths.begin(); path != raster_paths.end(); ++path)
rasters.push_back(FileIO::AsciiRasterInterface::getRasterFromASCFile(*path));
bool result = createRasterLayers(mesh, rasters, minimum_thickness, noDataReplacementValue);
std::for_each(rasters.begin(), rasters.end(), [](GeoLib::Raster const*const raster){ delete raster; });
return result;
}
示例14: createRasterLayers
bool MeshLayerMapper::createRasterLayers(
MeshLib::Mesh const& mesh,
std::vector<GeoLib::Raster const*> const& rasters,
double minimum_thickness,
double noDataReplacementValue)
{
const std::size_t nLayers(rasters.size());
if (nLayers < 2 || mesh.getDimension() != 2)
{
ERR("MeshLayerMapper::createRasterLayers(): A 2D mesh and at least two rasters required as input.");
return false;
}
auto top = std::make_unique<MeshLib::Mesh>(mesh);
if (!layerMapping(*top, *rasters.back(), noDataReplacementValue))
return false;
auto bottom = std::make_unique<MeshLib::Mesh>(mesh);
if (!layerMapping(*bottom, *rasters[0], 0))
{
return false;
}
this->_minimum_thickness = minimum_thickness;
std::size_t const nNodes = mesh.getNumberOfNodes();
_nodes.reserve(nLayers * nNodes);
// number of triangles in the original mesh
std::size_t const nElems (std::count_if(mesh.getElements().begin(), mesh.getElements().end(),
[](MeshLib::Element const* elem)
{ return (elem->getGeomType() == MeshLib::MeshElemType::TRIANGLE);}));
_elements.reserve(nElems * (nLayers-1));
_materials.reserve(nElems * (nLayers-1));
// add bottom layer
std::vector<MeshLib::Node*> const& nodes = bottom->getNodes();
for (MeshLib::Node* node : nodes)
_nodes.push_back(new MeshLib::Node(*node));
// add the other layers
for (std::size_t i=0; i<nLayers-1; ++i)
addLayerToMesh(*top, i, *rasters[i+1]);
return true;
}
示例15: createRasterLayers
bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh,
const std::vector<GeoLib::Raster const*> &rasters,
double minimum_thickness,
double noDataReplacementValue)
{
if (mesh.getDimension() != 2)
return false;
_elevation_epsilon = calcEpsilon(*rasters[0], *rasters.back());
if (_elevation_epsilon <= 0)
return false;
// remove line elements, only tri + quad remain
MeshLib::ElementSearch ex(mesh);
ex.searchByElementType(MeshLib::MeshElemType::LINE);
MeshLib::Mesh* top (removeElements(mesh, ex.getSearchedElementIDs(), "MeshLayer"));
if (top==nullptr)
top = new MeshLib::Mesh(mesh);
if (!MeshLib::MeshLayerMapper::layerMapping(*top, *rasters.back(), noDataReplacementValue))
return false;
MeshLib::Mesh* bottom (new MeshLib::Mesh(*top));
if (!MeshLib::MeshLayerMapper::layerMapping(*bottom, *rasters[0], 0))
{
delete top;
return false;
}
this->_minimum_thickness = minimum_thickness;
_nodes = MeshLib::copyNodeVector(bottom->getNodes());
_elements = MeshLib::copyElementVector(bottom->getElements(), _nodes);
delete bottom;
// map each layer and attach to subsurface mesh
const std::size_t nRasters (rasters.size());
for (std::size_t i=1; i<nRasters; ++i)
this->addLayerToMesh(*top, i, *rasters[i]);
// close boundaries between layers
this->addLayerBoundaries(*top, nRasters);
this->removeCongruentElements(nRasters, top->getNElements());
delete top;
return true;
}