[cig-commits] commit: Add Mesh_GetBasis and use it in _MeshParticleLayout_InitialiseParticlesOfCell
Mercurial
hg at geodynamics.org
Mon Sep 12 16:14:50 PDT 2011
changeset: 611:2fd6d91e1309
tag: tip
user: Walter Landry <wlandry at caltech.edu>
date: Mon Sep 12 14:38:51 2011 -0700
files: Mesh/src/MeshClass.cxx Mesh/src/MeshClass.h Swarm/src/MeshParticleLayout.cxx
description:
Add Mesh_GetBasis and use it in _MeshParticleLayout_InitialiseParticlesOfCell
diff -r c8652fabb55d -r 2fd6d91e1309 Mesh/src/MeshClass.cxx
--- a/Mesh/src/MeshClass.cxx Mon Sep 12 14:37:20 2011 -0700
+++ b/Mesh/src/MeshClass.cxx Mon Sep 12 14:38:51 2011 -0700
@@ -61,6 +61,7 @@ Mesh* Mesh_New( Name name, AbstractConte
Stg_Component_InitialiseFunction* _initialise = _Mesh_Initialise;
Stg_Component_ExecuteFunction* _execute = _Mesh_Execute;
Stg_Component_DestroyFunction* _destroy = _Mesh_Destroy;
+ Mesh_GetBasisFunction* _getBasis = _Mesh_GetBasis;
AllocationType nameAllocationType = NON_GLOBAL;
Mesh* self = _Mesh_New( MESH_PASSARGS );
@@ -75,7 +76,7 @@ Mesh* _Mesh_New( MESH_DEFARGS ) {
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Mesh) );
self = (Mesh*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
-
+ self->_getBasis=_getBasis;
return self;
}
@@ -114,6 +115,12 @@ void _Mesh_Init( Mesh* self, AbstractCon
self->requiresCheckpointing = False;
}
+/* +++ Virtual Function Interfaces +++ */
+void Mesh_GetBasis( void* mesh, double localCoord[], double* evaluatedValues ) {
+ Mesh* self = (Mesh*)mesh;
+
+ self->_getBasis( self, localCoord, evaluatedValues );
+}
/*----------------------------------------------------------------------------------------------------------------------------------
** Virtual functions
@@ -135,6 +142,7 @@ void _Mesh_Print( void* mesh, Stream* st
/* Print parent */
Journal_Printf( stream, "Mesh (ptr): (%p)\n", self );
+ Journal_Printf( stream, "\t_getBasis (func ptr): %p\n", self->_getBasis );
_Stg_Component_Print( self, stream );
}
@@ -228,6 +236,13 @@ void _Mesh_Destroy( void* mesh, void* da
NewClass_Delete( self->topo );
}
+void _Mesh_GetBasis( void* mesh, double localCoord[], double* evaluatedValues ) {
+ Mesh *self=(Mesh*)mesh;
+ Stream* error = Journal_Register( ErrorStream_Type, (Name)Mesh_Type );
+ Journal_Printf(error,"The mesh %s does not have a basis function",self->name);
+
+ abort();
+}
/*--------------------------------------------------------------------------------------------------------------------------
** Public Functions
diff -r c8652fabb55d -r 2fd6d91e1309 Mesh/src/MeshClass.h
--- a/Mesh/src/MeshClass.h Mon Sep 12 14:37:20 2011 -0700
+++ b/Mesh/src/MeshClass.h Mon Sep 12 14:38:51 2011 -0700
@@ -45,6 +45,8 @@
extern const Type Mesh_Type;
/** Virtual function types */
+ typedef void (Mesh_GetBasisFunction)(void* mesh,double *localCoord,
+ double* evaluatedValues);
/** Class contents */
#define __Mesh \
@@ -54,6 +56,7 @@
AbstractContext* context; \
/* Virtual info */ \
\
+ Mesh_GetBasisFunction* _getBasis; \
/* Mesh info */ \
MeshTopology* topo; \
double** verts; \
@@ -112,10 +115,12 @@
#endif
#define MESH_DEFARGS \
- STG_COMPONENT_DEFARGS
+ STG_COMPONENT_DEFARGS, \
+ Mesh_GetBasisFunction* _getBasis
#define MESH_PASSARGS \
- STG_COMPONENT_PASSARGS
+ STG_COMPONENT_PASSARGS, \
+ _getBasis
Mesh* Mesh_New( Name name, AbstractContext* context );
Mesh* _Mesh_New( MESH_DEFARGS );
@@ -200,8 +205,12 @@
void Mesh_GetDomainCoordRange( void* mesh, double* min, double* max );
void Mesh_GetGlobalCoordRange( void* mesh, double* min, double* max );
+ void Mesh_GetBasis( void* mesh, double *localCoord, double* basis );
+
void Mesh_DeformationUpdate( void* mesh );
void Mesh_Sync( void* mesh );
+
+ void _Mesh_GetBasis( void* elementType, double localCoord[], double* evaluatedValues );
/*--------------------------------------------------------------------------------------------------------------------------
** Private Member functions
diff -r c8652fabb55d -r 2fd6d91e1309 Swarm/src/MeshParticleLayout.cxx
--- a/Swarm/src/MeshParticleLayout.cxx Mon Sep 12 14:37:20 2011 -0700
+++ b/Swarm/src/MeshParticleLayout.cxx Mon Sep 12 14:38:51 2011 -0700
@@ -45,6 +45,9 @@
#include "SwarmClass.h"
#include "Random.h"
#include "StandardParticle.h"
+
+#include "StgFEM/Discretisation/ElementType.h"
+#include "StgFEM/Discretisation/FeMesh.h"
#include <stdio.h>
#include <stdlib.h>
@@ -245,23 +248,7 @@ void _MeshParticleLayout_InitialiseParti
localCoord[d_i] = Swarm_Random_Random_WithMinMax( min[d_i], max[d_i] );
}
- /* Convert the coordinate to global. Assumes quad or hex mesh. */
- if( nDims == 2 ) {
- basis[0] = 0.25 * (1.0 - localCoord[0]) * (1.0 - localCoord[1]);
- basis[1] = 0.25 * (1.0 + localCoord[0]) * (1.0 - localCoord[1]);
- basis[2] = 0.25 * (1.0 - localCoord[0]) * (1.0 + localCoord[1]);
- basis[3] = 0.25 * (1.0 + localCoord[0]) * (1.0 + localCoord[1]);
- }
- else {
- basis[0] = 0.125 * (1.0 - localCoord[0]) * (1.0 - localCoord[1]) * (1.0 - localCoord[2]);
- basis[1] = 0.125 * (1.0 + localCoord[0]) * (1.0 - localCoord[1]) * (1.0 - localCoord[2]);
- basis[2] = 0.125 * (1.0 - localCoord[0]) * (1.0 + localCoord[1]) * (1.0 - localCoord[2]);
- basis[3] = 0.125 * (1.0 + localCoord[0]) * (1.0 + localCoord[1]) * (1.0 - localCoord[2]);
- basis[4] = 0.125 * (1.0 - localCoord[0]) * (1.0 - localCoord[1]) * (1.0 + localCoord[2]);
- basis[5] = 0.125 * (1.0 + localCoord[0]) * (1.0 - localCoord[1]) * (1.0 + localCoord[2]);
- basis[6] = 0.125 * (1.0 - localCoord[0]) * (1.0 + localCoord[1]) * (1.0 + localCoord[2]);
- basis[7] = 0.125 * (1.0 + localCoord[0]) * (1.0 + localCoord[1]) * (1.0 + localCoord[2]);
- }
+ Mesh_GetBasis(self->mesh, localCoord, basis );
memset( particle->coord, 0, sizeof(double) * nDims );
for( d_i = 0; d_i < nDims; d_i++ ) {
More information about the CIG-COMMITS
mailing list