本文整理汇总了C++中MAKE_PTR函数的典型用法代码示例。如果您正苦于以下问题:C++ MAKE_PTR函数的具体用法?C++ MAKE_PTR怎么用?C++ MAKE_PTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAKE_PTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestAllBuskeForces
/**
* Create a simulation of a NodeBasedCellPopulation with all Buske forces.
* Test that no exceptions are thrown.
*/
void TestAllBuskeForces() throw (Exception)
{
EXIT_IF_PARALLEL; // HoneycombMeshGenerator doesn't work in parallel
// Create a simple mesh
HoneycombMeshGenerator generator(5, 5, 0);
TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();
// Convert this to a NodesOnlyMesh
NodesOnlyMesh<2> mesh;
mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);
// Create cells
std::vector<CellPtr> cells;
MAKE_PTR(TransitCellProliferativeType, p_transit_type);
CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes(), p_transit_type);
// Create a node-based cell population
NodeBasedCellPopulation<2> node_based_cell_population(mesh, cells);
// Set up cell-based simulation
OffLatticeSimulation<2> simulator(node_based_cell_population);
simulator.SetOutputDirectory("TestAllBuskeForces");
simulator.SetEndTime(5.0);
// Create a force law and pass it to the simulation
MAKE_PTR(BuskeCompressionForce<2>, p_buske_compression_force);
MAKE_PTR(BuskeElasticForce<2>, p_buske_elastic_force);
MAKE_PTR(BuskeAdhesiveForce<2>, p_buske_adhesive_force);
p_buske_compression_force->SetCompressionEnergyParameter(0.01);
simulator.AddForce(p_buske_compression_force);
simulator.AddForce(p_buske_elastic_force);
simulator.AddForce(p_buske_adhesive_force);
simulator.Solve();
}
示例2: TestOffLatticeSimulationWithCellHeightTrackingModifier
/*
* === Using the modifier in a cell-based simulation ===
*
* We conclude with a brief test demonstrating how {{{CellHeightTrackingModifier}}} can be used
* in a cell-based simulation.
*/
void TestOffLatticeSimulationWithCellHeightTrackingModifier()
{
/*
* In this case, we choose to create a small {{{NodeBasedCellPopulation}}} comprising 25 cells.
* We choose a cut-off for mechanical interactions between cells of 1.5 units and add a
* simple {{{ReplusionForce}}} to the simulation. We use a {{{UniformCellCycleModel}}}
* to implement some random proliferation in the simulation.
*/
HoneycombMeshGenerator generator(2, 2, 0);
TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();
NodesOnlyMesh<2> mesh;
mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);
std::vector<CellPtr> cells;
MAKE_PTR(TransitCellProliferativeType, p_transit_type);
CellsGenerator<UniformCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes(), p_transit_type);
NodeBasedCellPopulation<2> cell_population(mesh, cells);
OffLatticeSimulation<2> simulator(cell_population);
simulator.SetOutputDirectory("TestOffLatticeSimulationWithCellHeightTrackingModifier");
simulator.SetSamplingTimestepMultiple(12);
simulator.SetEndTime(20.0);
MAKE_PTR(RepulsionForce<2>, p_force);
simulator.AddForce(p_force);
/*
* Finally, we add a {{{CellHeightTrackingModifier}}} to the simulation.
*/
MAKE_PTR(CellHeightTrackingModifier, p_modifier);
simulator.AddSimulationModifier(p_modifier);
/* To run the simulation, we call {{{Solve()}}}. */
simulator.Solve();
}
开发者ID:Chaste,项目名称:Chaste,代码行数:43,代码来源:TestCreatingAndUsingANewCellBasedSimulationModifierTutorial.hpp
示例3: TestSave
void TestSave() throw (Exception)
{
EXIT_IF_PARALLEL;
PottsMeshGenerator<2> generator(10, 0, 0, 10, 0, 0);
PottsMesh<2>* p_mesh = generator.GetMesh();
std::vector<CellPtr> cells;
MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type);
CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, 10, p_diff_type);
std::vector<unsigned> location_indices;
for (unsigned index=0; index<10; index++)
{
location_indices.push_back(index);
}
CaBasedCellPopulation<2> cell_population(*p_mesh, cells, location_indices, 4);
// Set up cell-based simulation
OnLatticeSimulation<2> simulator(cell_population);
simulator.SetOutputDirectory("TestOnLatticeSimulationWithCaBasedCellPopulationSaveAndLoad");
simulator.SetDt(1);
simulator.SetEndTime(10);
// Add update rule
MAKE_PTR(DiffusionCaUpdateRule<2>, p_diffusion_update_rule);
p_diffusion_update_rule->SetDiffusionParameter(0.1);
simulator.AddCaUpdateRule(p_diffusion_update_rule);
// Run simulation
simulator.Solve();
// Save the results
CellBasedSimulationArchiver<2, OnLatticeSimulation<2> >::Save(&simulator);
}
示例4: TestSimpleMonolayerWithBuskeAdhesiveForce
/**
* Create a simulation of a NodeBasedCellPopulation with a BuskeInteractionForce system.
* Test that no exceptions are thrown, and write the results to file.
*/
void TestSimpleMonolayerWithBuskeAdhesiveForce() throw (Exception)
{
EXIT_IF_PARALLEL; // HoneycombMeshGenerator doesn't work in parallel
// Create a simple mesh
HoneycombMeshGenerator generator(5, 5, 0);
TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();
// Convert this to a NodesOnlyMesh
NodesOnlyMesh<2> mesh;
mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);
// Create cells
std::vector<CellPtr> cells;
CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes());
// Create a node-based cell population
NodeBasedCellPopulation<2> node_based_cell_population(mesh, cells);
// Set up cell-based simulation
OffLatticeSimulation<2> simulator(node_based_cell_population);
simulator.SetOutputDirectory("TestOffLatticeSimulationWithBuskeAdhesiveForce");
simulator.SetEndTime(5.0);
// Create a force law and pass it to the simulation
MAKE_PTR(BuskeAdhesiveForce<2>, p_buske_adhesive_force);
p_buske_adhesive_force->SetAdhesionEnergyParameter(0.002);
simulator.AddForce(p_buske_adhesive_force);
simulator.Solve();
// Check that nothing's gone badly wrong by testing that nodes aren't too close together
double min_distance_between_cells = 1.0;
for (unsigned i=0; i<simulator.rGetCellPopulation().GetNumNodes(); i++)
{
for (unsigned j=i+1; j<simulator.rGetCellPopulation().GetNumNodes(); j++)
{
double distance = norm_2(simulator.rGetCellPopulation().GetNode(i)->rGetLocation()-simulator.rGetCellPopulation().GetNode(j)->rGetLocation());
if (distance < min_distance_between_cells)
{
min_distance_between_cells = distance;
}
}
}
TS_ASSERT_LESS_THAN_EQUALS(1e-3, min_distance_between_cells);
}
示例5: TestSave
void TestSave() throw (Exception)
{
EXIT_IF_PARALLEL; // Potts simulations don't work in parallel because they depend on NodesOnlyMesh for writing.
// Create a simple 2D PottsMesh
PottsMeshGenerator<2> generator(10, 1, 4, 10, 1, 4);
PottsMesh<2>* p_mesh = generator.GetMesh();
// Create cells
std::vector<CellPtr> cells;
MAKE_PTR(StemCellProliferativeType, p_stem_type);
CellsGenerator<UniformlyDistributedGenerationBasedCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, p_mesh->GetNumElements(), p_stem_type);
// Create cell population
PottsBasedCellPopulation<2> cell_population(*p_mesh, cells);
// Set up cell-based simulation
OnLatticeSimulation<2> simulator(cell_population);
simulator.SetOutputDirectory("TestOnLatticeSimulationWithPottsBasedCellPopulationSaveAndLoad");
simulator.SetDt(0.1);
simulator.SetEndTime(10);
simulator.SetSamplingTimestepMultiple(10);
// Create update rules and pass to the simulation
MAKE_PTR(VolumeConstraintPottsUpdateRule<2>, p_volume_constraint_update_rule);
simulator.AddPottsUpdateRule(p_volume_constraint_update_rule);
MAKE_PTR(AdhesionPottsUpdateRule<2>, p_adhesion_update_rule);
simulator.AddPottsUpdateRule(p_adhesion_update_rule);
// Run simulation
simulator.Solve();
// Save the results
CellBasedSimulationArchiver<2, OnLatticeSimulation<2> >::Save(&simulator);
}
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:36,代码来源:TestOnLatticeSimulationWithPottsBasedCellPopulation.hpp
示例6: TestRandomCaSwitchingUpdateRuleIn2d
/*
* Now test the switching rules.
*/
void TestRandomCaSwitchingUpdateRuleIn2d()
{
// Set the timestep and size of domain to let us calculate the probabilities of movement
double delta_t = 0.1;
double delta_x = 1;
double switching_parameter = 0.1;
// Create an update law system
RandomCaSwitchingUpdateRule<2> random_switching_update_rule;
// Test get/set methods
TS_ASSERT_DELTA(random_switching_update_rule.GetSwitchingParameter(), 0.5, 1e-12);
random_switching_update_rule.SetSwitchingParameter(1.0);
TS_ASSERT_DELTA(random_switching_update_rule.GetSwitchingParameter(), 1.0, 1e-12);
random_switching_update_rule.SetSwitchingParameter(switching_parameter);
// Test EvaluateProbability()
// Create a simple 2D PottsMesh
PottsMeshGenerator<2> generator(3, 0, 0, 3, 0, 0);
PottsMesh<2>* p_mesh = generator.GetMesh();
// Create cells
std::vector<CellPtr> cells;
MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type);
CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, 6u, p_diff_type);
// Specify where cells lie here we have cells on the bottom two rows
std::vector<unsigned> location_indices;
for (unsigned i=0; i<6; i++)
{
location_indices.push_back(i);
}
// Create cell population
CaBasedCellPopulation<2u> cell_population(*p_mesh, cells, location_indices);
TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(0,1,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(0,6,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(0,5,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
// Note this is independent of node index and population so even returns for nodes not in the mesh
TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(UNSIGNED_UNSET,UNSIGNED_UNSET,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
}
示例7: RemoveFirst
/*
* RemoveFirst -- remove the first entry in the free list of ProcGlobal.
*
* Use compare_and_swap to avoid using lock and guarantee atomic operation.
*/
static PGPROC *
RemoveFirst()
{
volatile PROC_HDR *procglobal = ProcGlobal;
SHMEM_OFFSET myOffset;
PGPROC *freeProc = NULL;
/*
* Decrement numFreeProcs before removing the first entry from the
* free list.
*/
gp_atomic_add_32(&procglobal->numFreeProcs, -1);
int32 casResult = false;
while(!casResult)
{
myOffset = procglobal->freeProcs;
if (myOffset == INVALID_OFFSET)
{
break;
}
freeProc = (PGPROC *) MAKE_PTR(myOffset);
casResult = compare_and_swap_ulong(&((PROC_HDR *)procglobal)->freeProcs,
myOffset,
freeProc->links.next);
if (gp_debug_pgproc && !casResult)
{
elog(LOG, "need to retry allocating a PGPROC entry: pid=%d (oldHeadOffset=%ld, newHeadOffset=%ld)",
MyProcPid, myOffset, procglobal->freeProcs);
}
}
if (freeProc == NULL)
{
/*
* Increment numFreeProcs since we didn't remove any entry from
* the free list.
*/
gp_atomic_add_32(&procglobal->numFreeProcs, 1);
}
return freeProc;
}
示例8: AbstractCellCycleModel
StatechartCellCycleModelSerializable::StatechartCellCycleModelSerializable(bool LoadingFromArchive): AbstractCellCycleModel(){
mLoadingFromArchive=LoadingFromArchive;
TempVariableStorage=std::vector<double>();
TempStateStorage=0;
//Set some sensible C.Elegans germ cell defaults
mSDuration=8.33;
mG2Duration=6.66;
mMDuration=1.66;
mG1Duration=3.33;
mDimension=3;
mCurrentCellCyclePhase=G_ONE_PHASE;
MAKE_PTR(CellStatechart,newStatechart);
pStatechart=newStatechart;
};
示例9: TestCalculateWriteResultsToFile
void TestCalculateWriteResultsToFile()
{
std::string output_directory = "TestDiscreteSystemForceCalculator";
// Set up a cell population
HoneycombMeshGenerator mesh_generator(7, 5, 0, 2.0);
MutableMesh<2,2>* p_mesh = mesh_generator.GetMesh();
CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator;
std::vector<CellPtr> cells;
cells_generator.GenerateBasic(cells, p_mesh->GetNumNodes());
MeshBasedCellPopulation<2> cell_population(*p_mesh, cells);
// Create the force law and pass in to a std::list
MAKE_PTR(GeneralisedLinearSpringForce<2>, p_force);
std::vector<boost::shared_ptr<AbstractTwoBodyInteractionForce<2> > > force_collection;
force_collection.push_back(p_force);
// Create a force calculator
DiscreteSystemForceCalculator calculator(cell_population, force_collection);
// Test WriteResultsToFile
calculator.WriteResultsToFile(output_directory);
// Compare output with saved files of what they should look like
OutputFileHandler handler(output_directory, false);
std::string results_file = handler.GetOutputDirectoryFullPath() + "results_from_time_0/results.vizstress";
NumericFileComparison node_velocities(results_file, "cell_based/test/data/TestDiscreteSystemForceCalculator/results.vizstress");
TS_ASSERT(node_velocities.CompareFiles(1e-4));
// Run a simulation to generate some results.viz<other things> files
// so the visualizer can display the results.vizstress file.
// (These lines are not actually necessary for generating results.vizstress)
OffLatticeSimulation<2> simulator(cell_population);
simulator.AddForce(p_force);
simulator.SetEndTime(0.05);
simulator.SetOutputDirectory(output_directory+"_rerun");
simulator.Solve();
}
示例10: InitBufferPool
void
InitBufferPool () {
int i;
PrivateRefCount = (long *) malloc(NBuffers * sizeof(long));
// Altered to use regular memory
BufferDescriptors = (BufferDesc *) malloc (NBuffers * sizeof(BufferDesc));
BufferBlocks = (char *) malloc (NBuffers * BLCKSZ);
ShmemBase = BufferBlocks;
// ShmemBase = (unsigned long) BufferBlocks;
if (false)
{
}
else
{
BufferDesc *buf;
buf = BufferDescriptors;
for (i = 0; i < NBuffers; buf++, i++)
{
CLEAR_BUFFERTAG(buf->tag);
buf->flags = 0;
buf->usage_count = 0;
buf->refcount = 0;
buf->wait_backend_pid = 0;
buf->freeNext = i + 1;
buf->buf_id = i;
*((char *) MAKE_PTR(i * BLCKSZ)) = '#';
buf->io_in_progress_lock = LWLockAssign();
buf->content_lock = LWLockAssign();
}
/* close the circular queue */
BufferDescriptors[NBuffers - 1].freeNext = -1;
StrategyInitialize(true);
}
}
示例11: TestSave
// Testing Save
void TestSave() throw (Exception)
{
EXIT_IF_PARALLEL; // HoneycombMeshGenereator does not work in parallel
// Create a simple mesh
int num_cells_depth = 5;
int num_cells_width = 5;
HoneycombMeshGenerator generator(num_cells_width, num_cells_depth, 0);
TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();
// Convert this to a NodesOnlyMesh
NodesOnlyMesh<2> mesh;
mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);
// Create cells
std::vector<CellPtr> cells;
CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes());
// Create a node based cell population
NodeBasedCellPopulation<2> node_based_cell_population(mesh, cells);
// Set up cell-based simulation
OffLatticeSimulation<2> simulator(node_based_cell_population);
simulator.SetOutputDirectory("TestOffLatticeSimulationWithNodeBasedCellPopulationSaveAndLoad");
simulator.SetEndTime(0.1);
// Create a force law and pass it to the simulation
MAKE_PTR(GeneralisedLinearSpringForce<2>, p_linear_force);
p_linear_force->SetCutOffLength(1.5);
simulator.AddForce(p_linear_force);
// Create some boundary conditions and pass them to the simulation
c_vector<double,2> normal = zero_vector<double>(2);
normal(1) =-1.0;
MAKE_PTR_ARGS(PlaneBoundaryCondition<2>, p_bc, (&node_based_cell_population, zero_vector<double>(2), normal)); // y>0
simulator.AddCellPopulationBoundaryCondition(p_bc);
// Solve
simulator.Solve();
// Save the results
CellBasedSimulationArchiver<2, OffLatticeSimulation<2> >::Save(&simulator);
}
开发者ID:Pablo1990,项目名称:ChasteSimulation,代码行数:45,代码来源:TestOffLatticeSimulationWithNodeBasedCellPopulation.hpp
示例12: InitBufferPoolAccess
/*
* Initialize access to shared buffer pool
*
* This is called during backend startup (whether standalone or under the
* postmaster). It sets up for this backend's access to the already-existing
* buffer pool.
*
* NB: this is called before InitProcess(), so we do not have a PGPROC and
* cannot do LWLockAcquire; hence we can't actually access the bufmgr's
* shared memory yet. We are only initializing local data here.
*/
void
InitBufferPoolAccess(void)
{
int i;
/*
* Allocate and zero local arrays of per-buffer info.
*/
BufferBlockPointers = (Block *) calloc(NBuffers, sizeof(Block));
PrivateRefCount = (long *) calloc(NBuffers, sizeof(long));
BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8));
/*
* Convert shmem offsets into addresses as seen by this process. This
* is just to speed up the BufferGetBlock() macro.
*/
for (i = 0; i < NBuffers; i++)
BufferBlockPointers[i] = (Block) MAKE_PTR(BufferDescriptors[i].data);
}
示例13: TestMoreOnLatticeSimulationExceptions
void TestMoreOnLatticeSimulationExceptions()
{
// Create a simple 2D PottsMesh
PottsMeshGenerator<2> generator(6, 2, 2, 6, 2, 2);
PottsMesh<2>* p_mesh = generator.GetMesh();
// Create cells
std::vector<CellPtr> cells;
MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type);
CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
cells_generator.GenerateBasicRandom(cells, p_mesh->GetNumElements(), p_diff_type);
// Create cell population
PottsBasedCellPopulation<2> potts_based_cell_population(*p_mesh, cells);
// Try to set up off lattice simulation
TS_ASSERT_THROWS_THIS(OffLatticeSimulation<2> simulator(potts_based_cell_population),
"OffLatticeSimulations require a subclass of AbstractOffLatticeCellPopulation.");
}
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:19,代码来源:TestOnLatticeSimulationWithPottsBasedCellPopulation.hpp
示例14: GetOldestXmin
/*
* GetOldestXmin -- returns oldest transaction that was running
* when any current transaction was started.
*
* If allDbs is TRUE then all backends are considered; if allDbs is FALSE
* then only backends running in my own database are considered.
*
* This is used by VACUUM to decide which deleted tuples must be preserved
* in a table. allDbs = TRUE is needed for shared relations, but allDbs =
* FALSE is sufficient for non-shared relations, since only backends in my
* own database could ever see the tuples in them.
*
* Note: we include the currently running xids in the set of considered xids.
* This ensures that if a just-started xact has not yet set its snapshot,
* when it does set the snapshot it cannot set xmin less than what we compute.
*/
TransactionId
GetOldestXmin(bool allDbs)
{
SISeg *segP = shmInvalBuffer;
ProcState *stateP = segP->procState;
TransactionId result;
int index;
result = GetCurrentTransactionId();
LWLockAcquire(SInvalLock, LW_SHARED);
for (index = 0; index < segP->lastBackend; index++)
{
SHMEM_OFFSET pOffset = stateP[index].procStruct;
if (pOffset != INVALID_OFFSET)
{
PGPROC *proc = (PGPROC *) MAKE_PTR(pOffset);
if (allDbs || proc->databaseId == MyDatabaseId)
{
/* Fetch xid just once - see GetNewTransactionId */
TransactionId xid = proc->xid;
if (TransactionIdIsNormal(xid))
{
if (TransactionIdPrecedes(xid, result))
result = xid;
xid = proc->xmin;
if (TransactionIdIsNormal(xid))
if (TransactionIdPrecedes(xid, result))
result = xid;
}
}
}
}
LWLockRelease(SInvalLock);
return result;
}
示例15: ProcLockWakeup
/*
* ProcLockWakeup -- routine for waking up processes when a lock is
* released.
*/
int
ProcLockWakeup(PROC_QUEUE *queue, char *ltable, char *lock)
{
PROC *proc;
int count;
if (! queue->size)
return(STATUS_NOT_FOUND);
proc = (PROC *) MAKE_PTR(queue->links.prev);
count = 0;
while ((LockResolveConflicts ((LOCKTAB *) ltable,
(LOCK *) lock,
proc->token,
proc->xid) == STATUS_OK))
{
/* there was a waiting process, grant it the lock before waking it
* up. This will prevent another process from seizing the lock
* between the time we release the lock master (spinlock) and
* the time that the awoken process begins executing again.
*/
GrantLock((LOCK *) lock, proc->token);
queue->size--;
/*
* ProcWakeup removes proc from the lock waiting process queue and
* returns the next proc in chain. If a writer just dropped
* its lock and there are several waiting readers, wake them all up.
*/
proc = ProcWakeup(proc, NO_ERROR);
count++;
if (!proc || queue->size == 0)
break;
}
if (count)
return(STATUS_OK);
else
/* Something is still blocking us. May have deadlocked. */
return(STATUS_NOT_FOUND);
}