本文整理汇总了C++中PatchData::get_samples方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchData::get_samples方法的具体用法?C++ PatchData::get_samples怎么用?C++ PatchData::get_samples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchData
的用法示例。
在下文中一共展示了PatchData::get_samples方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notify_sub_patch
void CachingTargetCalculator::notify_sub_patch( PatchData& ,
CachedTargetData& data,
PatchData& subpatch,
const size_t* ,
const size_t* element_map,
MsqError& err )
{
// If no cached data for this patch, just return
if (data.has_data())
return;
// Create a new cached data object on the subpatch
CachedTargetData& sub_data = get_data( subpatch );
sub_data.clear();
// populate the element offset list, and count the total
// number of cached target matrices.
sub_data.elementOffsets.resize( subpatch.num_elements() );
size_t count_2D = 0, count_3D = 0;
for (size_t i = 0; i < subpatch.num_elements(); ++i) {
EntityTopology type = subpatch.element_by_index(i).get_element_type();
size_t& count = (TopologyInfo::dimension( type ) == 2) ? count_2D : count_3D;
sub_data.elementOffsets[i] = count;
NodeSet samples = subpatch.get_samples( i );
count += samples.num_nodes();
}
const bool orient = have_surface_orient();
sub_data.targets3D.resize( count_3D );
if (orient)
sub_data.targetsSurface.resize( count_2D );
else
sub_data.targets2D.resize( count_2D );
for (size_t i = 0; i < subpatch.num_elements(); ++i) {
EntityTopology type = subpatch.element_by_index(i).get_element_type();
size_t off = sub_data.elementOffsets[i];
size_t old_off = data.elementOffsets[element_map[i]];
NodeSet samples = subpatch.get_samples( i );
size_t count = samples.num_nodes();
if (TopologyInfo::dimension( type ) == 3)
memcpy( &sub_data.targets3D[off], &data.targets3D[old_off], count*sizeof(MsqMatrix<3,3>) );
else if (orient)
memcpy( &sub_data.targetsSurface[off], &data.targetsSurface[old_off], count*sizeof(MsqMatrix<3,2>) );
else
memcpy( &sub_data.targets2D[off], &data.targets2D[old_off], count*sizeof(MsqMatrix<2,2>) );
}
}
示例2: get_surface_target
bool CachingTargetCalculator::get_surface_target( PatchData& pd,
size_t element,
Sample sample,
MsqMatrix<3,2>& W_out,
MsqError& err )
{
CachedTargetData& data = get_data( pd );
if (data.targetsSurface.empty()) {
if (!have_surface_orient()) {
MSQ_SETERR(err)("Incorrect surface mesh target type", MsqError::INTERNAL_ERROR );
return false;
}
populate_data( pd, &data, cachedCalculator, err );
MSQ_ERRZERO(err);
if (data.targetsSurface.empty()) {
MSQ_SETERR(err)("Attempt to get 2D target for 3D element type", MsqError::INVALID_STATE);
return false;
}
}
// calculate index of sample in array
NodeSet all_samples = pd.get_samples( element );
unsigned offset = all_samples.num_before( sample );
W_out = data.targetsSurface[ data.elementOffsets[element] + offset ];
return true;
}
示例3: get_weight
double WeightReader::get_weight( PatchData &pd,
size_t element,
Sample sample,
MsqError& err )
{
WeightReaderData& data = get_data( pd );
// calculate index of sample in array
NodeSet all_samples = pd.get_samples( element );
unsigned offset = all_samples.num_before( sample );
if (!data.weights.empty() && data.elementIndex == element) {
assert(offset < data.weights.size());
return data.weights[offset];
}
const unsigned num_samples = all_samples.num_nodes();
const unsigned handle_idx = num_samples - 1;
// get the tag handle
const TagHandle INVALID_HANDLE = (TagHandle)-1;
if (data.handles.size() <= handle_idx)
data.handles.resize( handle_idx + 1, INVALID_HANDLE );
TagHandle& tag_handle = data.handles[handle_idx];
if (tag_handle == INVALID_HANDLE) {
tag_handle = get_tag( pd.get_mesh(),
num_samples,
tagBaseName.c_str(),
err );
MSQ_ERRZERO(err);
assert(tag_handle != INVALID_HANDLE);
}
// get the tag data
data.weights.resize( num_samples );
pd.get_mesh()->tag_get_element_data( tag_handle, 1,
pd.get_element_handles_array() + element,
&data.weights[0],
err );
if (MSQ_CHKERR(err)) {
data.weights.clear();
return false;
}
data.elementIndex = element;
assert(offset < num_samples);
return data.weights[offset];
}
示例4:
bool CachingTargetCalculator::get_3D_target( PatchData& pd,
size_t element,
Sample sample,
MsqMatrix<3,3>& W_out,
MsqError& err )
{
CachedTargetData& data = get_data( pd );
if (data.targets3D.empty()) {
populate_data( pd, &data, cachedCalculator, err );
MSQ_ERRZERO(err);
}
// calculate index of sample in array
NodeSet all_samples = pd.get_samples( element );
unsigned offset = all_samples.num_before( sample );
W_out = data.targets3D[ data.elementOffsets[element] + offset ];
return true;
}
示例5: populate_data
static void populate_data( PatchData& pd,
CachedTargetData* data,
TargetCalculator* calc,
MsqError& err )
{
size_t i, j;
const bool orient = calc->have_surface_orient();
if (data->elementOffsets.empty()) {
size_t count_3d = 0, count_2d = 0;
data->elementOffsets.resize( pd.num_elements() );
for (i = 0; i < pd.num_elements(); ++i) {
EntityTopology type = pd.element_by_index(i).get_element_type();
NodeSet sample_pts = pd.get_samples( i );
size_t& count = (TopologyInfo::dimension( type ) == 3) ? count_3d : count_2d;
data->elementOffsets[i] = count;
count += sample_pts.num_nodes();
}
data->targets3D.resize( count_3d );
if (orient)
data->targetsSurface.resize( count_2d );
else
data->targets2D.resize( count_2d );
}
size_t off2 = 0, off3 = 0;
for (i = 0; i < pd.num_elements(); ++i) {
EntityTopology type = pd.element_by_index(i).get_element_type();
NodeSet sample_pts = pd.get_samples( i );
if (TopologyInfo::dimension( type ) == 3) {
assert( off3 == data->elementOffsets[i] );
for (j = 0; j < TopologyInfo::corners(type); ++j) {
if (sample_pts.corner_node(j)) {
assert(off3 < data->targets3D.size());
calc->get_3D_target( pd, i, Sample(0,j), data->targets3D[off3++], err );
MSQ_ERRRTN(err);
}
}
for (j = 0; j < TopologyInfo::edges(type); ++j) {
if (sample_pts.mid_edge_node(j)) {
assert(off3 < data->targets3D.size());
calc->get_3D_target( pd, i, Sample(1,j), data->targets3D[off3++], err );
MSQ_ERRRTN(err);
}
}
for (j = 0; j < TopologyInfo::faces(type); ++j) {
if (sample_pts.mid_face_node(j)) {
assert(off3 < data->targets3D.size());
calc->get_3D_target( pd, i, Sample(2,j), data->targets3D[off3++], err );
MSQ_ERRRTN(err);
}
}
if (sample_pts.mid_region_node()) {
assert(off3 < data->targets3D.size());
calc->get_3D_target( pd, i, Sample(3,0), data->targets3D[off3++], err );
MSQ_ERRRTN(err);
}
}
else if (orient) {
assert( off2 == data->elementOffsets[i] );
for (j = 0; j < TopologyInfo::corners(type); ++j) {
if (sample_pts.corner_node(j)) {
assert(off2 < data->targetsSurface.size());
calc->get_surface_target( pd, i, Sample(0,j), data->targetsSurface[off2++], err );
MSQ_ERRRTN(err);
}
}
for (j = 0; j < TopologyInfo::edges(type); ++j) {
if (sample_pts.mid_edge_node(j)) {
assert(off2 < data->targetsSurface.size());
calc->get_surface_target( pd, i, Sample(1,j), data->targetsSurface[off2++], err );
MSQ_ERRRTN(err);
}
}
if (sample_pts.mid_face_node(0)) {
assert(off2 < data->targetsSurface.size());
calc->get_surface_target( pd, i, Sample(2,0), data->targetsSurface[off2++], err );
MSQ_ERRRTN(err);
}
}
else {
assert( off2 == data->elementOffsets[i] );
for (j = 0; j < TopologyInfo::corners(type); ++j) {
if (sample_pts.corner_node(j)) {
assert(off2 < data->targets2D.size());
calc->get_2D_target( pd, i, Sample(0,j), data->targets2D[off2++], err );
MSQ_ERRRTN(err);
}
}
for (j = 0; j < TopologyInfo::edges(type); ++j) {
if (sample_pts.mid_edge_node(j)) {
assert(off2 < data->targets2D.size());
calc->get_2D_target( pd, i, Sample(1,j), data->targets2D[off2++], err );
MSQ_ERRRTN(err);
}
}
if (sample_pts.mid_face_node(0)) {
assert(off2 < data->targets2D.size());
calc->get_2D_target( pd, i, Sample(2,0), data->targets2D[off2++], err );
MSQ_ERRRTN(err);
//.........这里部分代码省略.........
示例6: loop_over_mesh
double TargetWriter::loop_over_mesh( MeshDomainAssoc* mesh_and_domain,
const Settings* settings,
MsqError& err )
{
Mesh* mesh = mesh_and_domain->get_mesh();
MeshDomain* domain = mesh_and_domain->get_domain();
PatchData patch;
patch.set_mesh( mesh );
patch.set_domain( domain );
if (settings)
patch.attach_settings( settings );
ElementPatches patch_set;
patch_set.set_mesh( mesh );
std::vector<PatchSet::PatchHandle> patches;
std::vector<PatchSet::PatchHandle>::iterator p;
std::vector<Mesh::VertexHandle> patch_verts;
std::vector<Mesh::ElementHandle> patch_elems;
patch_set.get_patch_handles( patches, err ); MSQ_ERRZERO(err);
std::vector< MsqMatrix<3,3> > targets3d;
std::vector< MsqMatrix<3,2> > targets2dorient;
std::vector< MsqMatrix<2,2> > targets2d;
std::vector< double > weights;
std::vector< Sample > samples;
for (p = patches.begin(); p != patches.end(); ++p)
{
patch_verts.clear();
patch_elems.clear();
patch_set.get_patch( *p, patch_elems, patch_verts, err ); MSQ_ERRZERO(err);
patch.set_mesh_entities( patch_elems, patch_verts, err ); MSQ_ERRZERO(err);
assert(patch.num_elements() == 1);
MsqMeshEntity& elem = patch.element_by_index(0);
EntityTopology type = elem.get_element_type();
patch.get_samples( 0, samples, err ); MSQ_ERRZERO(err);
if (samples.empty())
continue;
if (targetCalc) {
const unsigned dim = TopologyInfo::dimension(type);
if (dim == 3) {
targets3d.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
targetCalc->get_3D_target( patch, 0, samples[i], targets3d[i], err ); MSQ_ERRZERO(err);
if (DBL_EPSILON > det(targets3d[i])) {
MSQ_SETERR(err)("Inverted 3D target", MsqError::INVALID_ARG);
return 0.0;
}
}
TagHandle tag = get_target_tag( 3, samples.size(), mesh, err ); MSQ_ERRZERO(err);
mesh->tag_set_element_data( tag, 1,
patch.get_element_handles_array(),
arrptr(targets3d), err ); MSQ_ERRZERO(err);
}
else if(targetCalc->have_surface_orient()) {
targets2dorient.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
targetCalc->get_surface_target( patch, 0, samples[i], targets2dorient[i], err ); MSQ_ERRZERO(err);
MsqMatrix<3,1> cross = targets2dorient[i].column(0) * targets2dorient[i].column(1);
if (DBL_EPSILON > (cross%cross)) {
MSQ_SETERR(err)("Degenerate 2D target", MsqError::INVALID_ARG);
return 0.0;
}
}
TagHandle tag = get_target_tag( 2, samples.size(), mesh, err ); MSQ_ERRZERO(err);
mesh->tag_set_element_data( tag, 1,
patch.get_element_handles_array(),
arrptr(targets2dorient), err ); MSQ_ERRZERO(err);
}
else {
targets2d.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
targetCalc->get_2D_target( patch, 0, samples[i], targets2d[i], err ); MSQ_ERRZERO(err);
if (DBL_EPSILON > det(targets2d[i])) {
MSQ_SETERR(err)("Degenerate/Inverted 2D target", MsqError::INVALID_ARG);
return 0.0;
}
}
TagHandle tag = get_target_tag( 2, samples.size(), mesh, err ); MSQ_ERRZERO(err);
mesh->tag_set_element_data( tag, 1,
patch.get_element_handles_array(),
arrptr(targets2d), err ); MSQ_ERRZERO(err);
}
}
if (weightCalc) {
weights.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
weights[i] = weightCalc->get_weight( patch, 0, samples[i], err ); MSQ_ERRZERO(err);
}
TagHandle tag = get_weight_tag( samples.size(), mesh, err ); MSQ_ERRZERO(err);
//.........这里部分代码省略.........