本文整理汇总了C++中utils::DynVector方法的典型用法代码示例。如果您正苦于以下问题:C++ utils::DynVector方法的具体用法?C++ utils::DynVector怎么用?C++ utils::DynVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::DynVector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testGeometryMode
void SolverInterfaceTestRemote:: testGeometryMode()
{
preciceTrace("testGeometryMode()");
using namespace tarch::la;
using utils::DynVector;
for (int dim=2; dim <= 3; dim++){
std::string configFilename;
if (dim == 2){
configFilename = _pathToTests + "geomode-2D.xml";
}
else {
configFilename = _pathToTests + "geomode-3D.xml";
}
int rank = utils::Parallel::getProcessRank();
if (rank == 0){
SolverInterface interface("TestAccessor", rank, 2);
configureSolverInterface(configFilename, interface);
validateEquals(interface.getDimensions(), dim);
int meshIDScalar = interface.getMeshID ( "AccessorMeshScalar" );
int meshIDVector = interface.getMeshID ( "AccessorMeshVector" );
DynVector pos(dim, 0.0);
int posIndex1 = interface.setMeshVertex ( meshIDScalar, raw(pos) );
assign(pos) = 1.0;
int posIndex2 = interface.setMeshVertex ( meshIDScalar, raw(pos) );
assign(pos) = 0.0;
int posIndex3 = interface.setMeshVertex ( meshIDVector, raw(pos) );
interface.initialize();
interface.initializeData(); // is skipped due to geometry mode
std::set<int> ids = interface.getMeshIDs();
typedef query::tests::GeometryTestScenarios GeoTests;
GeoTests geoTests;
// Test inquireClosestMesh()
const GeoTests::PointQueryScenario& pointScen = geoTests.pointQueryScenario(dim);
std::list<DynVector>::const_iterator coordIter = pointScen.queryCoords.begin();
std::list<double>::const_iterator distIter = pointScen.validDistances.begin();
std::list<DynVector>::const_iterator distVectorIter = pointScen.validDistanceVectors.begin();
DynVector distanceVec(dim);
while (coordIter != pointScen.queryCoords.end()){
ClosestMesh closest = interface.inquireClosestMesh(raw(*coordIter), ids);
for(int i=0; i<dim; i++) distanceVec[i] = closest.distanceVector()[i];
validate(equals(*distVectorIter, distanceVec));
validate(equals(*distIter, closest.distance()));
coordIter++;
distIter++;
distVectorIter++;
}
// Test inquirePosition()
const GeoTests::PositionQueryScenario& posScen = geoTests.positionQueryScenario(dim);
coordIter = posScen.queryCoords.begin();
std::list<int>::const_iterator posIter = posScen.validPositions.begin();
while ( coordIter != posScen.queryCoords.end() ){
int position = interface.inquirePosition ( raw(*coordIter), ids );
validateEquals ( position, *posIter );
coordIter ++;
posIter ++;
}
// Test inquireVoxelPosition()
const GeoTests::VoxelQueryScenario& voxelScen = geoTests.voxelQueryScenario(dim);
std::list<DynVector>::const_iterator centerIter = voxelScen.queryCenters.begin();
std::list<DynVector>::const_iterator hIter = voxelScen.queryHalflengths.begin();
std::list<bool>::const_iterator includeBoundsIter = voxelScen.includeBoundaries.begin();
posIter = voxelScen.validPositions.begin();
while ( centerIter != voxelScen.queryCenters.end() ){
VoxelPosition pos = interface.inquireVoxelPosition ( raw(*centerIter),
raw(*hIter), *includeBoundsIter, ids );
validateEquals ( pos.position(), *posIter );
centerIter ++;
hIter ++;
includeBoundsIter ++;
posIter ++;
}
// Test write data
int dataID = interface.getDataID ( "ScalarData", meshIDScalar );
double value = 1.0;
interface.writeScalarData ( dataID, posIndex1, value );
value = 2.0;
interface.writeScalarData ( dataID, posIndex2, value );
// Test read data (not really good test...)
dataID = interface.getDataID ( "VectorData", meshIDVector );
DynVector readValue(dim, 2.0);
interface.readVectorData ( dataID, posIndex3, raw(readValue) );
validate ( equals(readValue, DynVector(dim,0.0)) );
// Test exporting mesh
interface.exportMesh ( "remote" );
interface.advance(1.0);
interface.finalize();
//.........这里部分代码省略.........