[cig-commits] r3996 - in long/3D/Gale/trunk/src/StgFEM: .
Discretisation/src Discretisation/tests
SLE/ProvidedSystems/AdvectionDiffusion/tests
SLE/SystemSetup/tests plugins
plugins/CompareFeVariableAgainstReferenceSolution
plugins/FeVariableImportExporters
plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS
walter at geodynamics.org
walter at geodynamics.org
Sun Jul 9 14:36:41 PDT 2006
Author: walter
Date: 2006-07-09 14:36:40 -0700 (Sun, 09 Jul 2006)
New Revision: 3996
Added:
long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/
long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/
long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/FeVariable_ImportExport_ABAQUS.c
long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/makefile
long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/makefile
Modified:
long/3D/Gale/trunk/src/StgFEM/
long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h
long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Finalise.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Init.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/src/OperatorFeVariable.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-saveAndLoad.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-shadowing.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable.c
long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testIntegration.c
long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testLumpedMassMatrix.c
long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testSUPGShapeFunc.c
long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testSolutionVector.c
long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c
long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c
long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c
Log:
r684 at earth: boo | 2006-07-09 14:31:00 -0700
r681 at earth (orig r606): PatrickSunter | 2006-07-07 04:19:58 -0700
First pass at allowing import/export to other FE packages of StgFEM FeVariables:
* FeVariable now has an optional "importFormatType" and "exportFormatType" paramaters
(both are strings). Both default to "StgFEM_Native", which does the normal behaviour
* But user can over-ride these for things such as ABAQUS
* To add new importers/exporters, user must write a plugin to provide this functionality,
then register it with the global FeVariable_ImportExportType_Register, which will allow
you to specify the given import/export type
* Made the CompareFeVariableAgainstReference plugin aware of this so you can specify
different import types for your reference solution.
* Wrote an ABAQUS importer/exporter. The export function hasn't been written yet, so
so far you can only load from ABAQUS results. Also, by defualt ABAQUS puts the initial
co-ords in every timestep's output, so I've had to hack it by assuming the ABAQUS
file is for displacements, and adding the initial co-ords + nodal displacements '\
together to get the actual coords.
General improvements:
* The CompareFeVariableAgainstReference now outputs the actual error if you failed to
hit the tolerance, or if "alwaysOutputErrors" is specified in the root dictionary.
* Fixed a bug in the StgFEM_Native checkpoint reload which was causing it to not
calculate the correct co-ordinates of the mesh in parallel.
* Fixed another bug in same func such that BodyNodeLayout FeVariables don't update
the mesh geometry, since these nodes are at the centroids. Really, we should
checkpoint the mesh to a separate file.
Property changes on: long/3D/Gale/trunk/src/StgFEM
___________________________________________________________________
Name: svk:merge
- 38867592-cf10-0410-9e16-a142ea72ac34:/cig:683
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:605
+ 38867592-cf10-0410-9e16-a142ea72ac34:/cig:684
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:606
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -407,7 +407,9 @@
/* Create new FeVariable */
tmpName = Stg_Object_AppendSuffix( feVariable, "Analytic" );
- analyticFeVariable = FeVariable_New( tmpName, feVariable->feMesh, feVariable->geometryMesh, dofLayout, NULL, NULL, NULL, feVariable->dim, feVariable->fieldVariable_Register );
+ analyticFeVariable = FeVariable_New( tmpName, feVariable->feMesh, feVariable->geometryMesh, dofLayout,
+ NULL, NULL, NULL, feVariable->dim, feVariable->importFormatType,
+ feVariable->exportFormatType, feVariable->fieldVariable_Register );
/* Add new FeVariable to list */
Stg_ObjectList_Append( self->feVariableList, feVariable );
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -56,12 +56,16 @@
#include <assert.h>
#include <string.h>
-const Type FeVariable_Type = "FeVariable";
-const Name defaultFeVariableFeEquationNumberName = "defaultFeVariableFeEqName";
+const Type FeVariable_Type = "FeVariable";
+const Name defaultFeVariableFeEquationNumberName = "defaultFeVariableFeEqName";
+const char* StgFEM_Native_ImportExportType = "StgFEM_Native";
/* MPI Tags */
static const int DOF_VALUES_TAG = 10;
+/* Global objects */
+Stg_ObjectList* FeVariable_FileFormatImportExportList = NULL;
+
void* FeVariable_DefaultNew( Name name )
{
return _FeVariable_New(
@@ -94,10 +98,13 @@
NULL,
0,
0,
+ NULL,
+ NULL,
MPI_COMM_WORLD,
NULL );
}
+
FeVariable* FeVariable_New(
Name name,
void* feMesh,
@@ -107,6 +114,8 @@
void* ics,
void* linkedDofInfo,
Dimension_Index dim,
+ const char* const importFormatType,
+ const char* const exportFormatType,
FieldVariable_Register* fV_Register )
{
return FeVariable_New_Full(
@@ -120,6 +129,8 @@
NULL,
dofLayout->_totalVarCount,
dim,
+ importFormatType,
+ exportFormatType,
((Mesh*)feMesh)->layout->decomp->communicator,
fV_Register );
}
@@ -146,6 +157,8 @@
templateFeVariable,
templateFeVariable->fieldComponentCount,
templateFeVariable->dim,
+ templateFeVariable->importFormatType,
+ templateFeVariable->exportFormatType,
templateFeVariable->communicator,
fV_Register );
@@ -165,6 +178,8 @@
void* templateFeVariable,
Index fieldComponentCount,
Dimension_Index dim,
+ const char* const importFormatType,
+ const char* const exportFormatType,
MPI_Comm communicator,
FieldVariable_Register* fV_Register )
{
@@ -198,6 +213,8 @@
templateFeVariable,
fieldComponentCount,
dim,
+ importFormatType,
+ exportFormatType,
communicator,
fV_Register );
}
@@ -233,6 +250,8 @@
void* templateFeVariable,
Index fieldComponentCount,
Dimension_Index dim,
+ const char* const importFormatType,
+ const char* const exportFormatType,
MPI_Comm communicator,
FieldVariable_Register* fV_Register )
{
@@ -274,7 +293,8 @@
/* FeVariable info */
if( initFlag ){
- _FeVariable_Init( self, feMesh, geometryMesh, dofLayout, bcs, ics, linkedDofInfo, templateFeVariable );
+ _FeVariable_Init( self, feMesh, geometryMesh, dofLayout, bcs, ics, linkedDofInfo,
+ templateFeVariable, importFormatType, exportFormatType );
}
return self;
@@ -289,7 +309,9 @@
void* bcs,
void* ics,
void* linkedDofInfo,
- void* templateFeVariable )
+ void* templateFeVariable,
+ const char* const importFormatType,
+ const char* const exportFormatType )
{
/* General and Virtual info should already be set */
@@ -319,6 +341,38 @@
self->eqNum = FeEquationNumber_New( defaultFeVariableFeEquationNumberName, self->feMesh,
self->dofLayout, self->bcs, linkedDofInfo );
}
+
+ self->importFormatType = StG_Strdup( importFormatType );
+ /* check the given file format is actually among the registered list. If not, print them and exit. */
+ if( NULL == Stg_ObjectList_Get( FeVariable_FileFormatImportExportList, importFormatType ) ) {
+ Stream* errorStream = Journal_Register( Error_Type, self->type );
+
+ Journal_Printf( errorStream, "Error - in %s() - for FeVariable \"%s\": you specified this "
+ "FeVariable's import type as %s, which is not in the register of known "
+ "FeVariable import/export types\n.", __func__, self->name, importFormatType );
+ Journal_Printf( errorStream, "Currently registered import/export types are:\n" );
+ Stream_Indent( errorStream );
+ Stg_ObjectList_PrintAllEntryNames( FeVariable_FileFormatImportExportList, errorStream );
+ Stream_UnIndent( errorStream );
+
+ Journal_Firewall( 0, errorStream, "Exiting.\n" );
+ }
+
+ self->exportFormatType = StG_Strdup( exportFormatType );
+ /* check the given file format is actually among the registered list. If not, print them and exit. */
+ if( NULL == Stg_ObjectList_Get( FeVariable_FileFormatImportExportList, exportFormatType ) ) {
+ Stream* errorStream = Journal_Register( Error_Type, self->type );
+
+ Journal_Printf( errorStream, "Error - in %s() - for FeVariable \"%s\": you specified this "
+ "FeVariable's export type as %s, which is not in the register of known "
+ "FeVariable import/export types\n.", __func__, self->name, exportFormatType );
+ Journal_Printf( errorStream, "Currently registered import/export types are:\n" );
+ Stream_Indent( errorStream );
+ Stg_ObjectList_PrintAllEntryNames( FeVariable_FileFormatImportExportList, errorStream );
+ Stream_UnIndent( errorStream );
+
+ Journal_Firewall( 0, errorStream, "Exiting.\n" );
+ }
}
@@ -330,6 +384,8 @@
if( self->eqNum && ( NULL == self->templateFeVariable ) ) {
Stg_Class_Delete( self->eqNum );
}
+ Memory_Free( self->importFormatType );
+ Memory_Free( self->exportFormatType );
/* feMesh bc and doflayout are purposely not deleted */
/* Stg_Class_Delete parent*/
@@ -484,6 +540,8 @@
VariableCondition* bc = NULL;
VariableCondition* ic = NULL;
LinkedDofInfo* linkedDofInfo = NULL;
+ char* importFormatType = NULL;
+ char* exportFormatType = NULL;
_FieldVariable_Construct( self, cf );
@@ -494,10 +552,15 @@
ic = Stg_ComponentFactory_ConstructByKey( cf, self->name, "IC", VariableCondition, False ) ;
bc = Stg_ComponentFactory_ConstructByKey( cf, self->name, "BC", VariableCondition, False ) ;
linkedDofInfo = Stg_ComponentFactory_ConstructByKey( cf, self->name, "LinkedDofInfo", LinkedDofInfo, False );
+ importFormatType = Stg_ComponentFactory_GetString( cf, self->name, "importFormatType",
+ StgFEM_Native_ImportExportType );
+ exportFormatType = Stg_ComponentFactory_GetString( cf, self->name, "exportFormatType",
+ StgFEM_Native_ImportExportType );
self->fieldComponentCount = dofLayout->_totalVarCount;
- _FeVariable_Init( self, feMesh, geometryMesh, dofLayout, bc, ic, linkedDofInfo, NULL );
+ _FeVariable_Init( self, feMesh, geometryMesh, dofLayout, bc, ic, linkedDofInfo, NULL,
+ importFormatType, exportFormatType );
}
void _FeVariable_Initialise( void* variable, void* data ) {
@@ -1862,7 +1925,39 @@
}
+void FeVariable_ImportExportInfo_Delete( void* ptr ) {
+ /* Nothing to do - the ObjectAdaptor will take care of deleting the actual struct itself */
+}
+
+void FeVariable_ImportExportInfo_Print ( void* ptr, struct Stream* stream ) {
+ FeVariable_ImportExportInfo* importExportInfo = (FeVariable_ImportExportInfo*)ptr;
+
+ Journal_Printf( stream, "readNodalValuesFromFile (func ptr): %p", importExportInfo->readNodalValuesFromFile );
+ Journal_Printf( stream, "saveNodalValuesToFile (func ptr): %p", importExportInfo->saveNodalValuesToFile );
+}
+
+void* FeVariable_ImportExportInfo_Copy(
+ void* ptr,
+ void* dest,
+ Bool deep,
+ Name nameExt,
+ struct PtrMap* ptrMap ) {
+ // TODO
+ assert( 0 );
+}
+
+
void FeVariable_SaveToFile( void* feVariable, const char* prefixStr, unsigned int timeStep ) {
+ FeVariable* self = (FeVariable*)feVariable;
+ FeVariable_ImportExportInfo* importExportInfo;
+
+ importExportInfo = Stg_ObjectList_Get( FeVariable_FileFormatImportExportList, self->exportFormatType );
+ assert( importExportInfo );
+ importExportInfo->saveNodalValuesToFile( feVariable, prefixStr, timeStep );
+}
+
+
+void FeVariable_SaveNodalValuesToFile_StgFEM_Native( void* feVariable, const char* prefixStr, unsigned int timeStep ) {
FeVariable* self = (FeVariable*)feVariable;
char* filename;
Node_LocalIndex lNode_I = 0;
@@ -1920,13 +2015,23 @@
}
-/* Note: if we wish to support changing grid resolution half way through, then we'll need to make this function smarter,
-and probably save some mesh info as part of the CP so we can work out how to subsample (probably can then just create
-a temporary feVariable using the old size mesh, then keep calling InterpolateValueAt on it whereever our nodes are
-located, though this may not work easily in parallel ),. - PatrickSunter 9 Jun 2006
-*/
void FeVariable_ReadFromFile( void* feVariable, const char* prefixStr, unsigned int timeStep ) {
FeVariable* self = (FeVariable*)feVariable;
+ FeVariable_ImportExportInfo* importExportInfo;
+ /* Note: if we wish to support changing grid resolution half way through, then we'll need to make this function smarter,
+ and probably save some mesh info as part of the CP so we can work out how to subsample (probably can then just create
+ a temporary feVariable using the old size mesh, then keep calling InterpolateValueAt on it whereever our nodes are
+ located, though this may not work easily in parallel ),. - PatrickSunter 9 Jun 2006
+ */
+
+ importExportInfo = Stg_ObjectList_Get( FeVariable_FileFormatImportExportList, self->importFormatType );
+ assert( importExportInfo );
+ importExportInfo->readNodalValuesFromFile( feVariable, prefixStr, timeStep );
+}
+
+
+void FeVariable_ReadNodalValuesFromFile_StgFEM_Native( void* feVariable, const char* prefixStr, unsigned int timeStep ) {
+ FeVariable* self = (FeVariable*)feVariable;
char* filename;
Node_LocalIndex lNode_I = 0;
Node_GlobalIndex gNode_I = 0;
@@ -1939,6 +2044,8 @@
Processor_Index proc_I=0;
Dimension_Index dim_I=0;
BlockGeometry* geometry = (BlockGeometry*)self->feMesh->layout->elementLayout->geometry;
+ Coord localGeometryMin;
+ Coord localGeometryMax;
/* Necessary for now since we need to update the geometry min and max - see comment below */
Stg_CheckType( geometry, BlockGeometry );
@@ -1971,8 +2078,8 @@
/* Need to re-set the geometry here, in case we're loading from a checkpoint that had compression/squashing BCs,
and hence ended up with a smaller mesh than the original */
for ( dim_I = 0; dim_I < 3; dim_I++ ) {
- geometry->min[dim_I] = HUGE_VAL;
- geometry->max[dim_I] = -HUGE_VAL;
+ localGeometryMin[dim_I] = HUGE_VAL;
+ localGeometryMax[dim_I] = -HUGE_VAL;
}
while ( !feof(inputFile) ) {
@@ -1985,11 +2092,11 @@
&self->feMesh->nodeCoord[lNode_I][2] );
for ( dim_I = 0; dim_I < 3; dim_I++ ) {
- if ( self->feMesh->nodeCoord[lNode_I][dim_I] < geometry->min[dim_I] ) {
- geometry->min[dim_I] = self->feMesh->nodeCoord[lNode_I][dim_I];
+ if ( self->feMesh->nodeCoord[lNode_I][dim_I] < localGeometryMin[dim_I] ) {
+ localGeometryMin[dim_I] = self->feMesh->nodeCoord[lNode_I][dim_I];
}
- else if ( self->feMesh->nodeCoord[lNode_I][dim_I] > geometry->max[dim_I] ) {
- geometry->max[dim_I] = self->feMesh->nodeCoord[lNode_I][dim_I];
+ else if ( self->feMesh->nodeCoord[lNode_I][dim_I] > localGeometryMax[dim_I] ) {
+ localGeometryMax[dim_I] = self->feMesh->nodeCoord[lNode_I][dim_I];
}
}
@@ -2004,7 +2111,21 @@
}
fclose( inputFile );
+ /* Note: this is a bit of a hack - we really should be loading the mesh from a separate checkpoint file
+ anyway - but for now, we'll just check that its a CornerNL type eg velocity, since BodyNL node points
+ are at the centroids, and would hence stuff the Geometry object */
+ if ( self->feMesh->layout->nodeLayout->type == CornerNL_Type ) {
+ // TODO: separate into re-usable function
+ /* Since we could be loading in parallel, need to find global min and max of geometry */
+ for ( dim_I = 0; dim_I < 3; dim_I++ ) {
+ MPI_Allreduce( localGeometryMin, geometry->min, 3, MPI_DOUBLE, MPI_MIN,
+ self->feMesh->layout->decomp->communicator );
+ MPI_Allreduce( localGeometryMax, geometry->max, 3, MPI_DOUBLE, MPI_MAX,
+ self->feMesh->layout->decomp->communicator );
+ }
+ }
+
if ( Stg_Class_IsInstance( self->feMesh->layout->elementLayout, ParallelPipedHexaEL_Type ) ) {
ParallelPipedHexaEL_UpdateGeometryPartitionInfo( self->feMesh->layout->elementLayout, self->feMesh->layout->decomp );
}
-}
+}
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h 2006-07-09 21:36:40 UTC (rev 3996)
@@ -58,6 +58,34 @@
typedef void (FeVariable_InterpolateWithinElementFunction) (void* fieldVariable, Element_DomainIndex dElement_I, Coord xi, double* value );
typedef void (FeVariable_GetValueAtNodeFunction) (void* feVariable, Node_DomainIndex dNode_I, double* value );
+ /* Function prototypes for import / export */
+ typedef void (FeVariable_ReadNodalValuesFromFile_Function) (void* feVariable, const char* prefixStr, unsigned int timeStep );
+ typedef void (FeVariable_SaveNodalValuesToFile_Function) (void* feVariable, const char* prefixStr, unsigned int timeStep );
+
+ /** Struct containing info of how to read from / export to a certain file format */
+ /* We expect several of these guys to be registered in the Discretisation Init phase, and possibly by later
+ * plugins */
+ typedef struct FeVariable_ImportExportInfo {
+ FeVariable_ReadNodalValuesFromFile_Function* readNodalValuesFromFile;
+ FeVariable_SaveNodalValuesToFile_Function* saveNodalValuesToFile;
+ } FeVariable_ImportExportInfo;
+
+ void FeVariable_ImportExportInfo_Delete( void* ptr );
+ void FeVariable_ImportExportInfo_Print ( void* ptr, struct Stream* stream );
+ void* FeVariable_ImportExportInfo_Copy(
+ void* ptr,
+ void* dest,
+ Bool deep,
+ Name nameExt,
+ struct PtrMap* ptrMap );
+
+ /* A global list of import/export info objects - can be added to later by plugins. Needs to be initialised in
+ * FeDiscretisation_Init() */
+ // TODO: maybe should move this to the StgFEM_Context later???
+ extern Stg_ObjectList* FeVariable_FileFormatImportExportList;
+
+ extern const char* StgFEM_Native_ImportExportType;
+
/** FeVariable class contents */
#define __FeVariable \
/* General info */ \
@@ -88,7 +116,11 @@
/** Records whether the user has sync'd shadow values yet. */ \
Bool shadowValuesSynchronised; \
/** A "template" feVariable this one is based on - ie this one's mesh and BCs is based off that one */ \
- FeVariable* templateFeVariable;
+ FeVariable* templateFeVariable; \
+ /** A type recording what import/export system for loading and saving should be used */ \
+ char* importFormatType; \
+ char* exportFormatType;
+
/* Brings together and manages the life cycle of all the components required by the
Finite Element Method about a variable to be solved for - see FeVariable.h */
@@ -109,6 +141,8 @@
void* ics,
void* linkedDofInfo,
Dimension_Index dim,
+ const char* const importFormatType,
+ const char* const exportFormatType,
FieldVariable_Register* fV_Register );
/** Create a new FeVariable and initialises it. Mesh, bcs and eqNum table is based off a template one.
@@ -133,6 +167,8 @@
void* templateFeVariable,
Index fieldComponentCount,
Dimension_Index dim,
+ const char* const importFormatType,
+ const char* const exportFormatType,
MPI_Comm communicator,
FieldVariable_Register* fV_Register );
@@ -167,6 +203,8 @@
void* templateFeVariable,
Index fieldComponentCount,
Dimension_Index dim,
+ const char* const importFormatType,
+ const char* const exportFormatType,
MPI_Comm communicator,
FieldVariable_Register* fV_Register );
@@ -179,7 +217,9 @@
void* bcs,
void* ics,
void* linkedDofInfo,
- void* templateFeVariable );
+ void* templateFeVariable,
+ const char* const importFormatType,
+ const char* const exportFormatType );
/** Stg_Class_Delete a FeVariable construst */
void _FeVariable_Delete( void* variable );
@@ -211,7 +251,6 @@
/** Stg_Component_Initialise() implementation */
void _FeVariable_Initialise( void* variable, void* data );
-
/** Stg_Component_Execute() implementation */
void _FeVariable_Execute( void* variable, void* data );
@@ -265,9 +304,11 @@
/** Saves the current mesh coordinates, and value of each dof in the feVariable, to file */
void FeVariable_SaveToFile( void* feVariable, const char* prefixStr, unsigned int timeStep );
+ void FeVariable_SaveNodalValuesToFile_StgFEM_Native( void* feVariable, const char* prefixStr, unsigned int timeStep );
/** Reads in everything to initialise a built FeVariable from a file */
void FeVariable_ReadFromFile( void* feVariable, const char* prefixStr, unsigned int timeStep );
+ void FeVariable_ReadNodalValuesFromFile_StgFEM_Native( void* feVariable, const char* prefixStr, unsigned int timeStep );
/** Evaluates Spatial Derivatives using shape functions */
Bool FeVariable_InterpolateDerivativesAt( void* variable, Coord globalCoord, double* value ) ;
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Finalise.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Finalise.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Finalise.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -46,12 +46,18 @@
#include "shortcuts.h"
#include "Finalise.h"
+#include "FeVariable.h"
+
#include <stdio.h>
Bool StG_FEM_Discretisation_Finalise( void ) {
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
Stream_IndentBranch( StG_FEM_Debug );
+
+ Stg_ObjectList_DeleteAllObjects( FeVariable_FileFormatImportExportList );
+ Stg_Class_Delete( FeVariable_FileFormatImportExportList );
+
Stream_UnIndentBranch( StG_FEM_Debug );
return True;
}
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Init.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Init.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/Init.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -67,7 +67,8 @@
/** Initialises the Linear Algebra package, then any init for this package
such as streams etc */
Bool StG_FEM_Discretisation_Init( int* argc, char** argv[] ) {
- Stg_ComponentRegister* componentRegister = Stg_ComponentRegister_Get_ComponentRegister();
+ Stg_ComponentRegister* componentRegister = Stg_ComponentRegister_Get_ComponentRegister();
+ FeVariable_ImportExportInfo* stgFEM_NativeImportExportInfo = NULL;
int tmp;
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
@@ -108,5 +109,21 @@
/* initialise new MPI types */
FeEquationNumber_Create_CritPointInfo_MPI_Datatype();
+
+ /* Initialise singletons / registers */
+ FeVariable_FileFormatImportExportList = Stg_ObjectList_New();
+ /* Initially add the standard StgFEM import/export type */
+ stgFEM_NativeImportExportInfo = Memory_Alloc( FeVariable_ImportExportInfo, "stgFEM_NativeImportExportInfo" );
+ stgFEM_NativeImportExportInfo->readNodalValuesFromFile = FeVariable_ReadNodalValuesFromFile_StgFEM_Native;
+ stgFEM_NativeImportExportInfo->saveNodalValuesToFile = FeVariable_SaveNodalValuesToFile_StgFEM_Native;
+
+ Stg_ObjectList_PointerAppend(
+ FeVariable_FileFormatImportExportList,
+ stgFEM_NativeImportExportInfo,
+ StgFEM_Native_ImportExportType,
+ FeVariable_ImportExportInfo_Delete,
+ FeVariable_ImportExportInfo_Print,
+ FeVariable_ImportExportInfo_Copy );
+
return True;
}
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/OperatorFeVariable.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/OperatorFeVariable.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/OperatorFeVariable.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -240,6 +240,9 @@
NULL, /* Template FeVariable */
0 /* fieldComponentCount - this will be reset later */,
dim,
+ /* TODO: hack as always StgFEM_Native for now - PatrickSunter - 7 July 2006 */
+ StgFEM_Native_ImportExportType,
+ StgFEM_Native_ImportExportType,
communicator,
fV_Register );
@@ -383,7 +386,10 @@
}
- _FeVariable_Init( (FeVariable*) self, feVariableList[0]->feMesh, feVariableList[0]->geometryMesh, NULL, NULL, NULL, NULL, NULL );
+ _FeVariable_Init( (FeVariable*) self, feVariableList[0]->feMesh, feVariableList[0]->geometryMesh,
+ NULL, NULL, NULL, NULL, NULL,
+ // TODO: hack as always StgFEM native for now - PatrickSunter 7/7/2006
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType );
_OperatorFeVariable_Init( self, operatorName, feVariableCount, feVariableList );
Memory_Free( feVariableList );
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-saveAndLoad.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-saveAndLoad.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-saveAndLoad.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -196,7 +196,8 @@
/* Create the finite element field variable*/
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( "velocity", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim, fV_Register );
+ feVariable = FeVariable_New( "velocity", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
/* Apply some arbitrary initial conditions */
for ( i = 0; i < decomp->nodeDomainCount; i++ ) {
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-shadowing.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-shadowing.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable-shadowing.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -204,7 +204,8 @@
/* Create the finite element field variable*/
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( "velocity", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim, fV_Register );
+ feVariable = FeVariable_New( "velocity", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
/* Build and initialise system */
Build( wallVC, 0, False );
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeVariable.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -200,7 +200,8 @@
/* Create the finite element field variable*/
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( "velocity", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim, fV_Register );
+ feVariable = FeVariable_New( "velocity", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
/* Apply some arbitrary initial conditions */
for ( i = 0; i < decomp->nodeDomainCount; i++ ) {
Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testIntegration.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testIntegration.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testIntegration.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -206,7 +206,8 @@
/* Create the finite element field variable*/
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( "testField", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim, fV_Register );
+ feVariable = FeVariable_New( "testField", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
/* simulate solid body rotation */
geometry = (BlockGeometry*)eLayout->geometry;
Modified: long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testLumpedMassMatrix.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testLumpedMassMatrix.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testLumpedMassMatrix.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -192,7 +192,8 @@
/* Create the finite element field variable*/
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( "phi", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim, fV_Register );
+ feVariable = FeVariable_New( "phi", feMesh, NULL, dofs, wallVC, NULL, NULL, context->dim,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
/* Create Stream */
outputStream = Journal_Register( InfoStream_Type, CURR_MODULE_NAME );
Modified: long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testSUPGShapeFunc.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testSUPGShapeFunc.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/tests/testSUPGShapeFunc.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -230,7 +230,8 @@
}
/* Create the finite element field variable*/
- feVariable = FeVariable_New( "VelocityField", feMesh, NULL, dofs, NULL, NULL, NULL, context->dim, context->fieldVariable_Register );
+ feVariable = FeVariable_New( "VelocityField", feMesh, NULL, dofs, NULL, NULL, NULL, context->dim,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, context->fieldVariable_Register );
/* Swarm stuff */
if ( context->dim == 3 )
Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testSolutionVector.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testSolutionVector.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testSolutionVector.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -189,7 +189,8 @@
/* Create the fe variable and solution vector */
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( velocityName, feMesh, NULL, dofLayout, wallVC, NULL, NULL, 3, fV_Register );
+ feVariable = FeVariable_New( velocityName, feMesh, NULL, dofLayout, wallVC, NULL, NULL, 3,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
solnVec = SolutionVector_New( velocityName, CommWorld, feVariable);
/* Build and initialise system */
Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -226,7 +226,8 @@
/* Create the fe variable */
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( velocityName, feMesh, NULL, dofLayout, compositeVC, NULL, linkedDofInfo, numDims, fV_Register );
+ feVariable = FeVariable_New( velocityName, feMesh, NULL, dofLayout, compositeVC, NULL, linkedDofInfo, numDims,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
/* Create a hack swarm ptr - we won't actually use it in this test */
swarm = feVariable;
Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -222,7 +222,8 @@
/* Create the fe variable */
fV_Register = FieldVariable_Register_New();
- feVariable = FeVariable_New( velocityName, feMesh, NULL, dofLayout, compositeVC, NULL, NULL, numDims, fV_Register );
+ feVariable = FeVariable_New( velocityName, feMesh, NULL, dofLayout, compositeVC, NULL, NULL, numDims,
+ StgFEM_Native_ImportExportType, StgFEM_Native_ImportExportType, fV_Register );
/* Create a hack swarm ptr - we won't actually use it in this test */
swarm = feVariable;
Modified: long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -51,6 +51,7 @@
void CompareFeVariableAgainstReferenceSolution_TestAll( void* compareFeVariable, void* data );
void CompareFeVariableAgainstReferenceSolution_TestVariable( void* compareFeVariable, FeVariable* var, double tolerance );
+void _CompareFeVariableAgainstReferenceSolution_Delete( void* compareFeVariable );
typedef struct {
__Codelet
@@ -64,8 +65,15 @@
Stg_ObjectList* tolerances;
Index timeStepToCompare;
+
+ char* importFormatType;
+ char* exportFormatType;
+
+ char* referenceFeVariableSuffix;
+ Bool alwaysOutputErrors;
} CompareFeVariableAgainstReferenceSolution;
+
void _CompareFeVariableAgainstReferenceSolution_Construct( void* compareFeVariable, Stg_ComponentFactory* cf ) {
CompareFeVariableAgainstReferenceSolution* self = (CompareFeVariableAgainstReferenceSolution*) compareFeVariable;
@@ -95,6 +103,8 @@
CompareFeVariableAgainstReferenceSolution_TestAll,
self );
+ self->alwaysOutputErrors = Dictionary_GetBool_WithDefault( cf->rootDict, "alwaysOutputErrors", False );
+
dictionary = Dictionary_GetDictionary( cf->rootDict, self->name );
Journal_Firewall(
dictionary != NULL,
@@ -105,7 +115,7 @@
Journal_Printf(
Journal_MyStream( Info_Type, self ),
"%s: Using reference path %s\n", self->name, referencePath );
- self->referencePath = referencePath;
+ self->referencePath = StG_Strdup( referencePath );
integrationSwarmName = Dictionary_GetString_WithDefault( dictionary, "integrationSwarm", "gaussSwarm" );
Journal_Printf(
@@ -145,17 +155,26 @@
self->type );
}
+ self->importFormatType = StG_Strdup( Dictionary_GetString_WithDefault( dictionary, "importFormatType",
+ StgFEM_Native_ImportExportType ) );
+ self->exportFormatType = StG_Strdup( Dictionary_GetString_WithDefault( dictionary, "exportFormatType",
+ StgFEM_Native_ImportExportType ) );
+ self->referenceFeVariableSuffix = StG_Strdup( Dictionary_GetString_WithDefault( dictionary, "referenceFeVariabeSuffix",
+ "Reference" ) );
+
+
myStream = Journal_MyStream( Info_Type, self );
Stg_asprintf( &tmpName, "%s.dat", self->name );
Stream_RedirectFile_WithPrependedPath( myStream, self->context->outputPath, tmpName );
Memory_Free( tmpName );
}
+
void* _CompareFeVariableAgainstReferenceSolution_DefaultNew( Name name ) {
return _Codelet_New(
sizeof(CompareFeVariableAgainstReferenceSolution),
CompareFeVariableAgainstReferenceSolution_Type,
- _Codelet_Delete,
+ _CompareFeVariableAgainstReferenceSolution_Delete,
_Codelet_Print,
_Codelet_Copy,
_CompareFeVariableAgainstReferenceSolution_DefaultNew,
@@ -167,6 +186,7 @@
name );
}
+
Index _StG_FEM_CompareFeVariableAgainstReferenceSolution_Register( PluginsManager* pluginsManager ) {
return PluginsManager_Submit(
pluginsManager,
@@ -175,6 +195,7 @@
_CompareFeVariableAgainstReferenceSolution_DefaultNew );
}
+
void CompareFeVariableAgainstReferenceSolution_TestAll( void* compareFeVariable, void* data ) {
CompareFeVariableAgainstReferenceSolution* self = (CompareFeVariableAgainstReferenceSolution*) compareFeVariable;
@@ -200,6 +221,7 @@
}
}
+
void CompareFeVariableAgainstReferenceSolution_TestVariable( void* compareFeVariable, FeVariable* var, double tolerance ) {
CompareFeVariableAgainstReferenceSolution* self = (CompareFeVariableAgainstReferenceSolution*) compareFeVariable;
@@ -306,7 +328,12 @@
dofLayout->dofCounts[0] = var->dofLayout->dofCounts[0];
/* Instantiate FeVariable, pre-reading reference */
- refName = Stg_Object_AppendSuffix( var, "Reference" );
+ if ( strlen( self->referenceFeVariableSuffix ) > 0 ) {
+ refName = Stg_Object_AppendSuffix( var, self->referenceFeVariableSuffix );
+ }
+ else {
+ refName = var->name;
+ }
ref = FeVariable_New(
refName,
var->feMesh,
@@ -316,6 +343,8 @@
NULL,
NULL,
var->dim,
+ self->importFormatType,
+ self->exportFormatType,
var->fieldVariable_Register );
Stg_asprintf( &prefix, "%s/", self->referencePath );
@@ -341,6 +370,13 @@
result <= tolerance ? "within" : "outside",
tolerance );
+ if ( ( result > tolerance ) || (True == self->alwaysOutputErrors) ) {
+ Journal_Printf(
+ Journal_MyStream( Info_Type, self ),
+ "\t(Integrated total error was %g)\n",
+ result );
+ }
+
/*
Stg_Class_Delete( dataVariable );
Stg_Class_Delete( dofLayout );
@@ -348,5 +384,13 @@
Stg_Class_Delete( errorField );
Stg_Class_Delete( errorMagnitudeField );
*/
+}
-}
+void _CompareFeVariableAgainstReferenceSolution_Delete( void* compareFeVariable ) {
+ CompareFeVariableAgainstReferenceSolution* self = (CompareFeVariableAgainstReferenceSolution*) compareFeVariable;
+
+ Memory_Free( self->referencePath );
+ Memory_Free( self->referenceFeVariableSuffix );
+ Memory_Free( self->importFormatType );
+ Memory_Free( self->exportFormatType );
+}
Added: long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/FeVariable_ImportExport_ABAQUS.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/FeVariable_ImportExport_ABAQUS.c 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/FeVariable_ImportExport_ABAQUS.c 2006-07-09 21:36:40 UTC (rev 3996)
@@ -0,0 +1,258 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+** Melbourne, 3053, Australia.
+**
+** Primary Contributing Organisations:
+** Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+** Australian Computational Earth Systems Simulator - http://www.access.edu.au
+** Monash Cluster Computing - http://www.mcc.monash.edu.au
+** Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+**
+** Contributors:
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+** Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+** Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+** Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id$
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StG_FEM/StG_FEM.h>
+
+#include <string.h>
+
+const Type StG_FEM_FeVariable_ImportExport_ABAQUS_Type = "StG_FEM_FeVariable_ImportExport_ABAQUS";
+const char* ABAQUS_ImportExportType = "ABAQUS";
+
+
+void FeVariable_ReadNodalValuesFromFile_ABAQUS( void* _feVariable, const char* prefixStr, unsigned int timeStep ) {
+ FeVariable* feVariable = (FeVariable*)_feVariable;
+ char* filename;
+ Node_LocalIndex lNode_I = 0;
+ Node_GlobalIndex gNode_I = 0;
+ Node_GlobalIndex gNodeCount_I = 0;
+ Dof_Index dof_I;
+ Dof_Index dofAtEachNodeCount;
+ FILE* inputFile;
+ double variableVal;
+ char lineString[1000];
+ const unsigned int MAX_LINE_LENGTH = 1000;
+ Processor_Index proc_I=0;
+ Dimension_Index dim_I=0;
+ BlockGeometry* geometry = (BlockGeometry*)feVariable->feMesh->layout->elementLayout->geometry;
+ char* matchString;
+ Index currentFileLine = 0;
+ Coord localGeometryMin;
+ Coord localGeometryMax;
+ Stream* debugStream = Journal_Register( Debug_Type, StG_FEM_FeVariable_ImportExport_ABAQUS_Type );
+
+ Journal_DPrintf( debugStream, "In %s(): for FeVariable \"%s\"\n", __func__, feVariable->name );
+ Stream_Indent( debugStream );
+
+ /* Necessary for now since we need to update the geometry min and max - see comment below */
+ Stg_CheckType( geometry, BlockGeometry );
+
+ /* prefix feVariable->name . 00000 . dat \0 */
+ filename = Memory_Alloc_Array_Unnamed( char, strlen(prefixStr) + strlen(feVariable->name) + 1 + 5 + 1 + 3 + 1 );
+ sprintf( filename, "%s%s.%.5u.rpt", prefixStr, feVariable->name, timeStep );
+
+ /* TODO May need/want to change to MPI file stuff */
+
+ /* This loop used to stop 2 processors trying to open the file at the same time, which
+ * seems to cause problems */
+ for ( proc_I = 0; proc_I < feVariable->feMesh->layout->decomp->nproc; proc_I++ ) {
+ MPI_Barrier( feVariable->feMesh->layout->decomp->communicator );
+ if ( proc_I == feVariable->feMesh->layout->decomp->rank ) {
+ inputFile = fopen( filename, "r" );
+ }
+ }
+
+ if ( False == inputFile ) {
+ Stream* errorStr = Journal_Register( Error_Type, feVariable->type );
+ Journal_Printf( errorStr, "Error- in %s(), for feVariable \"%s\": Couldn't find checkpoint file with "
+ "prefix \"%s\", timestep %d - thus full filename \"%s\" - aborting.\n", __func__, feVariable->name,
+ prefixStr, timeStep, filename );
+ exit(EXIT_FAILURE);
+ }
+
+ /* This is where we skip over the ABAQUS header stuff */
+ while ( !feof(inputFile) ) {
+ currentFileLine++;
+ fgets( lineString, MAX_LINE_LENGTH, inputFile );
+ matchString = strstr( lineString, " Node" );
+ if ( matchString != NULL ) {
+ /* Grab the "Label" and the "----" lines */
+ fgets( lineString, MAX_LINE_LENGTH, inputFile );
+ fgets( lineString, MAX_LINE_LENGTH, inputFile );
+ currentFileLine += 2;
+ /* Ok, now we're ready to start reading the actual field values */
+ break;
+ }
+ }
+ Journal_DPrintf( debugStream, "Skipped %u lines of ABAQUS header info...\n", currentFileLine );
+
+ dofAtEachNodeCount = feVariable->fieldComponentCount;
+
+ /* Need to re-set the geometry here, in case we're loading from a checkpoint that had compression/squashing BCs,
+ and hence ended up with a smaller mesh than the original */
+ for ( dim_I = 0; dim_I < 3; dim_I++ ) {
+ localGeometryMin[dim_I] = HUGE_VAL;
+ localGeometryMax[dim_I] = -HUGE_VAL;
+ }
+
+ Journal_DPrintf( debugStream, "Processing Nodal Data...\n", currentFileLine );
+ Stream_Indent( debugStream );
+ /* Note: in ABAQUS, the number of lines of nodal values from hereon is always == the number of global nodes */
+ for ( gNodeCount_I = 0; gNodeCount_I < feVariable->feMesh->nodeGlobalCount; gNodeCount_I++ ) {
+ fscanf( inputFile, "%u ", &gNode_I );
+ /* Note: ABAQUS has same layout of global node indices as StgFEM, except it indexes starting from 1 - thus we
+ * need to subtract 1 here */
+ gNode_I -= 1;
+
+ lNode_I = Mesh_NodeMapGlobalToLocal( feVariable->feMesh, gNode_I );
+ Journal_DPrintfL( debugStream, 3, "Found info for global node %u, local node %u:\n", gNode_I, lNode_I );
+ Stream_Indent( debugStream );
+
+ if ( lNode_I != Mesh_Node_Invalid( feVariable->feMesh ) ) {
+ /* Note: until we have proper mesh geometry, topology etc checkpointing, we re-load the
+ node co-ords from the feVariable file - and also update the geometry */
+ fscanf( inputFile, "%lg %lg ",
+ &feVariable->feMesh->nodeCoord[lNode_I][0],
+ &feVariable->feMesh->nodeCoord[lNode_I][1] );
+ if ( feVariable->fieldComponentCount == 3 ) {
+ fscanf( inputFile, "%lg",
+ &feVariable->feMesh->nodeCoord[lNode_I][2] );
+ }
+ else {
+ feVariable->feMesh->nodeCoord[lNode_I][2] = 0.0;
+ }
+
+ Journal_DPrintfL( debugStream, 3, "read coord (%.3f, %.3f, %.3f)\n",
+ feVariable->feMesh->nodeCoord[lNode_I][0],
+ feVariable->feMesh->nodeCoord[lNode_I][1],
+ feVariable->feMesh->nodeCoord[lNode_I][2] );
+
+ for ( dof_I = 0; dof_I < dofAtEachNodeCount; dof_I++ ) {
+ fscanf( inputFile, "%lg ", &variableVal );
+ DofLayout_SetValueDouble( feVariable->dofLayout, lNode_I, dof_I, variableVal );
+ Journal_DPrintfL( debugStream, 3, "read dof %u: %g\n", dof_I, variableVal );
+ /* TODO: Hack for now - ABAQUS only uses initial coords, so assume this is displacement and add */
+ feVariable->feMesh->nodeCoord[lNode_I][dof_I] += variableVal;
+ Journal_DPrintfL( debugStream, 3, "TODO: using HACK assumption of disp.:- updating nodeCoord[%u] to %.3f\n",
+ dof_I, feVariable->feMesh->nodeCoord[lNode_I][dof_I] );
+ }
+
+ for ( dim_I = 0; dim_I < 3; dim_I++ ) {
+ if ( feVariable->feMesh->nodeCoord[lNode_I][dim_I] < localGeometryMin[dim_I] ) {
+ localGeometryMin[dim_I] = feVariable->feMesh->nodeCoord[lNode_I][dim_I];
+ }
+ else if ( feVariable->feMesh->nodeCoord[lNode_I][dim_I] > localGeometryMax[dim_I] ) {
+ localGeometryMax[dim_I] = feVariable->feMesh->nodeCoord[lNode_I][dim_I];
+ }
+ }
+
+ }
+ else {
+ Journal_DPrintfL( debugStream, 3, "not on current proc -> skipping\n" );
+ fgets( lineString, MAX_LINE_LENGTH, inputFile );
+ }
+ Stream_UnIndent( debugStream );
+ currentFileLine++;
+ }
+ fclose( inputFile );
+ Stream_UnIndent( debugStream );
+
+ /* Since we could be loading in parallel, need to find global min and max of geometry */
+ for ( dim_I = 0; dim_I < 3; dim_I++ ) {
+ MPI_Allreduce( localGeometryMin, geometry->min, 3, MPI_DOUBLE, MPI_MIN,
+ feVariable->feMesh->layout->decomp->communicator );
+ MPI_Allreduce( localGeometryMax, geometry->max, 3, MPI_DOUBLE, MPI_MAX,
+ feVariable->feMesh->layout->decomp->communicator );
+ }
+
+ Journal_DPrintf( debugStream, "Recalculated global field min coord as (%.3f, %.3f, %.3f)\n",
+ geometry->min[0], geometry->min[1], geometry->min[2] );
+ Journal_DPrintf( debugStream, "Recalculated global field max coord as (%.3f, %.3f, %.3f)\n",
+ geometry->max[0], geometry->max[1], geometry->max[2] );
+
+ if ( Stg_Class_IsInstance( feVariable->feMesh->layout->elementLayout, ParallelPipedHexaEL_Type ) ) {
+ ParallelPipedHexaEL_UpdateGeometryPartitionInfo( feVariable->feMesh->layout->elementLayout, feVariable->feMesh->layout->decomp );
+ }
+
+ Stream_UnIndent( debugStream );
+}
+
+
+void FeVariable_SaveNodalValuesToFile_ABAQUS( void* _feVariable, const char* prefixStr, unsigned int timeStep ) {
+ FeVariable* feVariable = (FeVariable*)_feVariable;
+ Stream* errorStream = Journal_Register( Error_Type, StG_FEM_FeVariable_ImportExport_ABAQUS_Type );
+
+ Journal_Firewall( 0, errorStream, "Error - in %s(), for FeVariable \"%s\": function not implemented yet.\n",
+ __func__, feVariable->name );
+}
+
+
+void _StG_FEM_FeVariable_ImportExport_ABAQUS_Construct( void* componment, Stg_ComponentFactory* cf ) {
+ AbstractContext* context;
+ FeVariable_ImportExportInfo* abaqusImportExportInfo = NULL;
+
+ context = Stg_ComponentFactory_ConstructByName( cf, "context", AbstractContext, True );
+
+ abaqusImportExportInfo = Memory_Alloc( FeVariable_ImportExportInfo, "ABAQUS_ImportExportInfo" );
+ abaqusImportExportInfo->readNodalValuesFromFile = FeVariable_ReadNodalValuesFromFile_ABAQUS;
+ abaqusImportExportInfo->saveNodalValuesToFile = FeVariable_SaveNodalValuesToFile_ABAQUS;
+
+ Stg_ObjectList_PointerAppend(
+ FeVariable_FileFormatImportExportList,
+ abaqusImportExportInfo,
+ ABAQUS_ImportExportType,
+ FeVariable_ImportExportInfo_Delete,
+ FeVariable_ImportExportInfo_Print,
+ FeVariable_ImportExportInfo_Copy );
+}
+
+void* _StG_FEM_FeVariable_ImportExport_ABAQUS_DefaultNew( Name name ) {
+ return _Codelet_New(
+ sizeof( Codelet ),
+ StG_FEM_FeVariable_ImportExport_ABAQUS_Type,
+ _Codelet_Delete,
+ _Codelet_Print,
+ _Codelet_Copy,
+ _StG_FEM_FeVariable_ImportExport_ABAQUS_DefaultNew,
+ _StG_FEM_FeVariable_ImportExport_ABAQUS_Construct,
+ _Codelet_Build,
+ _Codelet_Initialise,
+ _Codelet_Execute,
+ _Codelet_Destroy,
+ name );
+}
+
+Index StG_FEM_FeVariable_ImportExport_ABAQUS_Register( PluginsManager* pluginsManager ) {
+ return PluginsManager_Submit( pluginsManager, StG_FEM_FeVariable_ImportExport_ABAQUS_Type, "0", _StG_FEM_FeVariable_ImportExport_ABAQUS_DefaultNew );
+}
+
+
Property changes on: long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/FeVariable_ImportExport_ABAQUS.c
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate Author Id
Name: svn:eol-style
+ native
Added: long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/makefile 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/FeVariable_ImportExport_ABAQUS/makefile 2006-07-09 21:36:40 UTC (rev 3996)
@@ -0,0 +1,59 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+## Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+## Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+## Australian Computational Earth Systems Simulator - http://www.access.edu.au
+## Monash Cluster Computing - http://www.mcc.monash.edu.au
+## Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+## Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+## Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+## Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+## David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+## Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+## Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+## Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+## Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+## Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+## Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+## $Id: makefile 535 2006-04-11 13:07:34Z PatrickSunter $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SHELL := $(shell which bash)
+PROJ_ROOT := $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+
+modName := $(shell basename `pwd` )
+modName := $(shell echo ${modName} | cut -c 1 | tr '[:lower:]' '[:upper:]' )$(shell echo ${modName} | cut -c 2- )
+
+mod = ${PROJECT}_${modName}
+includes = ${PROJECT}/${modName}
+
+SRCS = $(wildcard *.c)
+HDRS = $(wildcard *.h)
+
+packages = STGERMAIN PETSC MPI XML
+EXTERNAL_LIBS = -lStG_FEM
+
+include ${PROJ_ROOT}/Makefile.vmake
Added: long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/makefile 2006-07-09 21:36:37 UTC (rev 3995)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/FeVariableImportExporters/makefile 2006-07-09 21:36:40 UTC (rev 3996)
@@ -0,0 +1,56 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+## Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+## Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+## Australian Computational Earth Systems Simulator - http://www.access.edu.au
+## Monash Cluster Computing - http://www.mcc.monash.edu.au
+## Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+## Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+## Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+## Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+## David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+## Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+## Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+## Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+## Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+## Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+## Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+## $Id: makefile 588 2006-06-20 02:02:24Z AlanLo $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+subdirs = \
+ MultiGrid \
+ Output \
+ StandardConditionFunctions \
+ Document \
+ LevelSetPlugin \
+ VelicAnalyticSolutions \
+ CompareFeVariableAgainstReferenceSolution
+
+# obtain defaults for required variables according to system and project location, and then run the build.
+SHELL := $(shell which bash)
+PROJ_ROOT:= $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+include ${PROJ_ROOT}/Makefile.vmake
More information about the cig-commits
mailing list