// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setCellAttributeMatrixPath( reader->readDataArrayPath("CellAttributeMatrixPath", getCellAttributeMatrixPath() ) ); setXMin( reader->readValue("XMin", getXMin()) ); setYMin( reader->readValue("YMin", getYMin()) ); setZMin( reader->readValue("ZMin", getZMin()) ); setXMax( reader->readValue("XMax", getXMax()) ); setYMax( reader->readValue("YMax", getYMax()) ); setZMax( reader->readValue("ZMax", getZMax()) ); reader->closeFilterGroup(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setCellAttributeMatrixPaths( reader->readDataArrayPathVector("CellAttributeMatrixPaths", getCellAttributeMatrixPaths() ) ); setXMin( reader->readValue("XMin", getXMin()) ); setYMin( reader->readValue("YMin", getYMin()) ); setZMin( reader->readValue("ZMin", getZMin()) ); setXMax( reader->readValue("XMax", getXMax()) ); setYMax( reader->readValue("YMax", getYMax()) ); setZMax( reader->readValue("ZMax", getZMax()) ); setInitType(reader->readValue("InitType", getInitType())); setInitValue(reader->readValue("InitValue", getInitValue())); setInitRange(reader->readPairOfDoubles("InitRange", getInitRange())); reader->closeFilterGroup(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CropImageGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setNewDataContainerName( reader->readString("NewDataContainerName", getNewDataContainerName() ) ); setCellAttributeMatrixPath( reader->readDataArrayPath("CellAttributeMatrixPath", getCellAttributeMatrixPath() ) ); setCellFeatureAttributeMatrixPath( reader->readDataArrayPath("CellFeatureAttributeMatrixPath", getCellFeatureAttributeMatrixPath() ) ); setFeatureIdsArrayPath(reader->readDataArrayPath("FeatureIdsArrayPath", getFeatureIdsArrayPath() ) ); setXMin( reader->readValue("XMin", getXMin()) ); setYMin( reader->readValue("YMin", getYMin()) ); setZMin( reader->readValue("ZMin", getZMin()) ); setXMax( reader->readValue("XMax", getXMax()) ); setYMax( reader->readValue("YMax", getYMax()) ); setZMax( reader->readValue("ZMax", getZMax()) ); setRenumberFeatures( reader->readValue("RenumberFeatures", getRenumberFeatures()) ); setSaveAsNewDataContainer( reader->readValue("SaveAsNewDataContainer", getSaveAsNewDataContainer()) ); setUpdateOrigin( reader->readValue("UpdateOrigin", getUpdateOrigin()) ); reader->closeFilterGroup(); }
void setupInitialConditions() { relVelocity_ = 1e-1; setName("AdhesiveForceUnitTest_ParticleWallInteractionWithPlasticForces"); setSystemDimensions(3); setParticleDimensions(3); setGravity(Vec3D(0,0,0)); species->setDensity(2000.0); species->setStiffness(1e2); species->setAdhesionStiffness(1e2); species->setAdhesionForceMax(1e-5*species->getAdhesionStiffness()); Mdouble R = 1e-3; species->setSlidingStiffness(1.2e1); species->setSlidingFrictionCoefficient(0.01); setTimeStep(5e-6 / 2.0); setXMax( 2*R); setYMax( R); setZMax( R); setXMin(0); setYMin(-R); setZMin(-R); particleHandler.clear(); BaseParticle P; P.setRadius(R); P.setPosition(Vec3D(R+species->getInteractionDistance()*1/3,0,0)); P.setVelocity(Vec3D(-relVelocity_/2,0,0)); particleHandler.copyAndAddObject(P); wallHandler.clear(); InfiniteWall w; w.set(Vec3D(-1, 0, 0), Vec3D(getXMin(), 0, 0)); wallHandler.copyAndAddObject(w); setTimeMax(getTimeStep()*250*4); setFileType(FileType::ONE_FILE); setSaveCount(1); }
void setupInitialConditions() { setParticleDimensions(3); setXMax(2); setYMax(2); setZMax(2); setSystemDimensions(3); species->setDensity(6.0 / constants::pi); setGravity(Vec3D(0.0, 0.0, 0.0)); species->setCollisionTimeAndRestitutionCoefficient(0.01, 1.0, 1.0); setTimeStep(0.0002); setTimeMax(1.0); setSaveCount(helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep(20, getTimeMax(), getTimeStep())); //set particles particle->setRadius(0.5); particle->setPosition(Vec3D(1.0, 1.0, 1.0)); particle->setVelocity(Vec3D(0.0, 0.0, -1.0)); //set walls wall->setNormal(Vec3D(0.0, 0.0, -1.0)); }
void setupInitialConditions() { if (particleHandler.getNumberOfObjects() != N) { particleHandler.clear(); boundaryHandler.clear(); double VP = constants::pi * 4.0 / 3.0; L = pow(N * VP * DistInt(1, omega) / nu, 1.0 / 3.0); setXMin(0); setYMin(0); setZMin(0); setXMax(L); setYMax(L); setZMax(L); PeriodicBoundary b0; b0.set(Vec3D(1, 0, 0), getXMin(), getXMax()); boundaryHandler.copyAndAddObject(b0); b0.set(Vec3D(0, 1, 0), getYMin(), getYMax()); boundaryHandler.copyAndAddObject(b0); b0.set(Vec3D(0, 0, 1), getZMin(), getZMax()); boundaryHandler.copyAndAddObject(b0); particleHandler.setStorageCapacity(2 * N); BaseParticle p0; p0.setVelocity(Vec3D(0.0, 0.0, 0.0)); double V = 0; //Use at least particles with maximum and minimum size p0.setRadius(1.0); Vec3D position; position.Z = random.getRandomNumber(0, getZMax()); position.Y = random.getRandomNumber(0, getYMax()); position.X = random.getRandomNumber(0, getXMax()); p0.setPosition(position); particleHandler.copyAndAddObject(p0); V += VP * pow(p0.getRadius(), 3); p0.setRadius(omega); position.Z = random.getRandomNumber(0, getZMax()); position.Y = random.getRandomNumber(0, getYMax()); position.X = random.getRandomNumber(0, getXMax()); p0.setPosition(position); particleHandler.copyAndAddObject(p0); V += VP * pow(p0.getRadius(), 3); //For other particles use a random distribution for (unsigned int i = 2; i < N; i++) { p0.setRadius(RandomRadius()); position.Z = random.getRandomNumber(0, getZMax()); position.Y = random.getRandomNumber(0, getYMax()); position.X = random.getRandomNumber(0, getXMax()); p0.setPosition(position); particleHandler.copyAndAddObject(p0); V += VP * pow(p0.getRadius(), 3); } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CropImageGeometry::dataCheck() { if(getErrorCondition() < 0) { return; } setErrorCondition(0); // Validate the incoming DataContainer, Geometry, and AttributeMatrix ; bail if any do not exist since we plan on using them later on in the dataCheck // Error messages are handled by the getPrereq functions DataContainer::Pointer srcCellDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName()); ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName()); AttributeMatrix::Pointer srcCellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellAttributeMatrixPath(), -301); if(getErrorCondition() < 0) { return; } DataContainer::Pointer destCellDataContainer = srcCellDataContainer; AttributeMatrix::Pointer destCellAttrMat; if (m_SaveAsNewDataContainer == true) { float ox = 0.0f, oy = 0.0f, oz = 0.0f, rx = 0.0f, ry = 0.0f, rz = 0.0f; size_t dx = 0, dy = 0, dz = 0; image->getOrigin(ox, oy, oz); image->getResolution(rx, ry, rz); image->getDimensions(dx, dy, dz); destCellDataContainer = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getNewDataContainerName()); if(NULL == destCellDataContainer.get() || getErrorCondition() < 0) { return; } IGeometry::Pointer imageCopy = image->deepCopy(); destCellDataContainer->setGeometry(imageCopy); destCellAttrMat = srcCellAttrMat->deepCopy(); destCellDataContainer->addAttributeMatrix(destCellAttrMat->getName(), destCellAttrMat); } else { destCellAttrMat = srcCellAttrMat; } if(NULL == destCellDataContainer.get() || NULL == destCellAttrMat.get() || getErrorCondition() < 0) { return; } if (getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getXMin() < 0) { QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getYMin() < 0) { QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getZMin() < 0) { QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getXMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1)) { QString ss = QObject::tr("The X Max (%1) is greater than the Image Geometry X extent (%2)").arg(getXMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getYMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1)) { QString ss = QObject::tr("The Y Max (%1) is greater than the Image Geometry Y extent (%2)").arg(getYMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getZMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getZPoints()) - 1)) { QString ss = QObject::tr("The Z Max (%1) is greater than the Image Geometry Z extent (%2)").arg(getZMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getZPoints()) - 1); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } QVector<size_t> tDims(3, 0); if (getXMax() - getXMin() < 0) { setXMax(getXMin() + 1); } if (getYMax() - getYMin() < 0) { setYMax(getYMin() + 1); } if (getZMax() - getZMin() < 0) { setZMax(getZMin() + 1); } tDims[0] = (getXMax() - getXMin()) + 1; tDims[1] = (getYMax() - getYMin()) + 1; tDims[2] = (getZMax() - getZMin()) + 1; destCellDataContainer->getGeometryAs<ImageGeom>()->setDimensions(tDims[0], tDims[1], tDims[2]); // If any of the sanity checks fail above then we should NOT attempt to go any further. if (getErrorCondition() < 0) { return; } size_t totalPoints = 1; for(int i = 0; i < 3; i++) { if(tDims[i] != 0) { totalPoints *= tDims[i]; } } AttributeMatrix::Pointer newCellAttrMat = AttributeMatrix::New(tDims, destCellAttrMat->getName(), destCellAttrMat->getType()); QList<QString> voxelArrayNames = destCellAttrMat->getAttributeArrayNames(); for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) { IDataArray::Pointer p = destCellAttrMat->getAttributeArray(*iter); // IDataArray::Pointer data = p->createNewArray(totalPoints, p->getComponentDimensions(), p->getName(), false); destCellAttrMat->removeAttributeArray(*iter); newCellAttrMat->addAttributeArray(*iter, data); } destCellDataContainer->removeAttributeMatrix(destCellAttrMat->getName()); destCellDataContainer->addAttributeMatrix(newCellAttrMat->getName(), newCellAttrMat); if(m_RenumberFeatures == true) { QVector<size_t> cDims(1, 1); m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getFeatureIdsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ AttributeMatrix::Pointer cellFeatureAttrMat = srcCellDataContainer->getAttributeMatrix(getCellFeatureAttributeMatrixPath().getAttributeMatrixName()); if(NULL == cellFeatureAttrMat.get()) { return; } QVector<bool> activeObjects(cellFeatureAttrMat->getNumTuples(), true); cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock()); } }