[cig-commits] commit: Add NearestNeighbor_Replace and make BuoyancyForceTerm use it
Mercurial
hg at geodynamics.org
Sat Oct 22 19:25:38 PDT 2011
changeset: 434:d24a5fb96d0c
tag: tip
user: Walter Landry <wlandry at caltech.edu>
date: Sat Oct 22 19:24:00 2011 -0700
files: MaterialPoints/src/NearestNeighborMapper.cxx MaterialPoints/src/NearestNeighborMapper.h Utils/src/BuoyancyForceTerm.cxx
description:
Add NearestNeighbor_Replace and make BuoyancyForceTerm use it
diff -r 3e4bed8e279d -r d24a5fb96d0c MaterialPoints/src/NearestNeighborMapper.cxx
--- a/MaterialPoints/src/NearestNeighborMapper.cxx Sun Oct 16 05:45:07 2011 -0700
+++ b/MaterialPoints/src/NearestNeighborMapper.cxx Sat Oct 22 19:24:00 2011 -0700
@@ -244,3 +244,30 @@ int NearestNeighbor_FindNeighbor(void* m
}
return nearest_particle;
}
+
+/* A convenience function to replace the gauss swarm and particle with
+ the mapped swarm and nearest particle */
+
+void NearestNeighbor_Replace
+(IntegrationPointsSwarm **swarm, IntegrationPoint **particle,
+ int *particle_index, const Element_LocalIndex &lElement_I,
+ const int &dim)
+{
+ if(Stg_Class_IsInstance((*swarm)->mapper,NearestNeighborMapper_Type))
+ {
+ IntegrationPointsSwarm* NNswarm=
+ ((NearestNeighborMapper*)((*swarm)->mapper))->swarm;
+ int NNcell_I=
+ CellLayout_MapElementIdToCellId(NNswarm->cellLayout,lElement_I);
+ int nearest_particle=
+ NearestNeighbor_FindNeighbor((*swarm)->mapper,lElement_I,
+ NNcell_I,(*particle)->xi,dim);
+ IntegrationPoint *NNparticle=
+ (IntegrationPoint*)Swarm_ParticleInCellAt(NNswarm,
+ NNcell_I,
+ nearest_particle);
+ *swarm=NNswarm;
+ *particle=NNparticle;
+ *particle_index=NNswarm->cellParticleTbl[NNcell_I][nearest_particle];
+ }
+}
diff -r 3e4bed8e279d -r d24a5fb96d0c MaterialPoints/src/NearestNeighborMapper.h
--- a/MaterialPoints/src/NearestNeighborMapper.h Sun Oct 16 05:45:07 2011 -0700
+++ b/MaterialPoints/src/NearestNeighborMapper.h Sat Oct 22 19:24:00 2011 -0700
@@ -121,4 +121,18 @@ void _NearestNeighborMapper_Init( void*
const int &cell_I,
double *xi, const int &dim);
+ void NearestNeighbor_Replace(IntegrationPointsSwarm **swarm,
+ IntegrationPoint **particle,
+ int *particle_index,
+ const Element_LocalIndex &lElement_I,
+ const int &dim);
+
+ inline void NearestNeighbor_Replace(IntegrationPointsSwarm **swarm,
+ IntegrationPoint **particle,
+ const Element_LocalIndex &lElement_I,
+ const int &dim)
+ {
+ int temp(0);
+ NearestNeighbor_Replace(swarm,particle,&temp,lElement_I,dim);
+ }
#endif
diff -r 3e4bed8e279d -r d24a5fb96d0c Utils/src/BuoyancyForceTerm.cxx
--- a/Utils/src/BuoyancyForceTerm.cxx Sun Oct 16 05:45:07 2011 -0700
+++ b/Utils/src/BuoyancyForceTerm.cxx Sat Oct 22 19:24:00 2011 -0700
@@ -462,24 +462,10 @@ void _BuoyancyForceTerm_AssembleElement(
swarm */
IntegrationPointsSwarm* NNswarm(swarm);
IntegrationPoint* NNparticle(particle);
-
- if(Stg_Class_IsInstance(swarm->mapper,NearestNeighborMapper_Type))
- {
- NNswarm=((NearestNeighborMapper*)(swarm->mapper))->swarm;
- int NNcell_I=
- CellLayout_MapElementIdToCellId(NNswarm->cellLayout,
- lElement_I);
- int nearest_particle=
- NearestNeighbor_FindNeighbor(swarm->mapper,lElement_I,
- NNcell_I,particle->xi,dim);
- NNparticle=
- (IntegrationPoint*)Swarm_ParticleInCellAt(NNswarm,
- NNcell_I,
- nearest_particle);
- }
+ NearestNeighbor_Replace(&NNswarm,&NNparticle,lElement_I,dim);
/* Get density and alpha */
- uint material_index=
+ unsigned int material_index=
IntegrationPointMapper_GetMaterialIndexOn(NNswarm->mapper,
NNparticle);
Journal_Firewall(material_index<densities.size()
More information about the CIG-COMMITS
mailing list