Example #1
0
void _lucViewport_Print( void* viewport, Stream* stream )
{
   lucViewport*          self        = viewport;

   Journal_Printf( stream, "lucViewport: %s\n", self->name );

   Stream_Indent( stream );

   /* Print Parent */
   _Stg_Component_Print( self, stream );

   lucDrawingObject_Register_PrintAllObjects( self->drawingObject_Register, stream );

   Stg_Class_Print( self->camera, stream );

   Journal_PrintValue( stream, self->margin );
   Journal_PrintValue( stream, self->nearClipPlane );
   Journal_PrintValue( stream, self->farClipPlane );

   Journal_PrintString( stream, self->title );
   Journal_PrintBool( stream, self->timestep );
   Journal_PrintBool( stream, self->disabled );

   Stream_UnIndent( stream );
}
void _FieldVariable_Print( void* _fieldVariable, Stream* stream ) {
   FieldVariable* self = (FieldVariable*) _fieldVariable;

   Journal_Printf( stream, "FieldVariable - '%s'\n", self->name );
   Stream_Indent( stream );
   _Stg_Component_Print( self, stream );

   Journal_PrintPointer( stream, self->_interpolateValueAt );
   Journal_PrintPointer( stream, self->_getMinGlobalFieldMagnitude );
   Journal_PrintPointer( stream, self->_getMaxGlobalFieldMagnitude );
   Journal_PrintPointer( stream, self->_cacheMinMaxGlobalFieldMagnitude );
   Journal_PrintPointer( stream, self->_getMinAndMaxLocalCoords );
   Journal_PrintPointer( stream, self->_getMinAndMaxGlobalCoords );

   Journal_PrintValue( stream, self->fieldComponentCount );
   Journal_PrintValue( stream, self->dim );
   Journal_PrintBool( stream, self->isCheckpointedAndReloaded);
   #ifdef LAM_MPI
      Journal_PrintPointer( stream, self->communicator );
   #elif  defined( OPEN_MPI )
      Journal_PrintPointer( stream, self->communicator );
   #else
      Journal_PrintValue( stream, self->communicator );
   #endif
   Journal_PrintPointer( stream, self->fieldVariable_Register );
   Stream_UnIndent( stream );
}
void _Stokes_SLE_UzawaSolver_Print( void* solver, Stream* stream ) {
	Stokes_SLE_UzawaSolver* self = (Stokes_SLE_UzawaSolver*)solver;

	_SLE_Solver_Print( self, stream );

	Journal_PrintValue( stream, self->tolerance );
	Journal_PrintValue( stream, self->maxUzawaIterations );
	Journal_PrintValue( stream, self->minUzawaIterations );
}
void _ViscousPenaltyConstMatrixCartesian_Print( void* constitutiveMatrix, Stream* stream ) {
	ViscousPenaltyConstMatrixCartesian* self = (ViscousPenaltyConstMatrixCartesian*)constitutiveMatrix;
	
	_ConstitutiveMatrix_Print( self, stream );

	/* General info */
	
	Journal_PrintValue( stream, self->incompressibility_Penalty );
	Journal_PrintValue( stream, self->viscosityWeighting );
	
}
Example #5
0
void _Matrix_NaiNbj_Print( void* constitutiveMatrix, Stream* stream ) {
	Matrix_NaiNbj* self = (Matrix_NaiNbj*)constitutiveMatrix;
	
	_ConstitutiveMatrix_Print( self, stream );

	/* General info */
	
	Journal_PrintValue( stream, self->incompressibility_Penalty );
	Journal_PrintValue( stream, self->viscosityWeighting );
	
}
void _OperatorSwarmVariable_Print( void* _swarmVariable, Stream* stream ) {
	OperatorSwarmVariable* self = (OperatorSwarmVariable*) _swarmVariable;
	Index                  swarmVariable_I;

	_SwarmVariable_Print( self, stream );

	Journal_PrintValue( stream, self->swarmVariableCount );
	for ( swarmVariable_I = 0 ; swarmVariable_I < self->swarmVariableCount ; swarmVariable_I++ ) 
		Journal_Printf( stream, "\tSwarmVariable %u - '%s'\n", swarmVariable_I, self->swarmVariableList[ swarmVariable_I ]->name );

}
Example #7
0
void _LinearRegression_Print( void* _linearRegression, Stream* stream ) {
	LinearRegression* self = (LinearRegression*) _linearRegression;
	Journal_Printf( stream, "LinearRegression\n" );

	Journal_PrintValue( stream, self->xMean );
	Journal_PrintValue( stream, self->yMean );
	Journal_PrintValue( stream, self->slope );
	Journal_PrintValue( stream, self->interceptor );
	Journal_PrintValue( stream, self->slopeStandardError );
	Journal_PrintValue( stream, self->interceptorStandardError );
	Journal_PrintValue( stream, self->correlationCoefficient );
}
void _SLE_Solver_Print( void* sleSolver, Stream* stream ) {
	SLE_Solver*		self = (SLE_Solver*)sleSolver;

	_Stg_Component_Print( self, stream );

	Journal_PrintPointer( stream, self->extensionManager );
	
	Journal_PrintPointer( stream, self->_solverSetup );
	Journal_PrintPointer( stream, self->_solve );
	Journal_PrintPointer( stream, self->_getResidual );

	Journal_PrintPointer( stream, self->debug );
	Journal_PrintValue( stream, self->maxIterations );
}
Example #9
0
void _SwarmVariable_Print( void* _swarmVariable, Stream* stream ) {
	SwarmVariable* self = (SwarmVariable*) _swarmVariable;

	Journal_Printf( stream, "SwarmVariable - '%s'\n", self->name );
	Stream_Indent( stream );
	_Stg_Component_Print( self, stream );

	Journal_PrintPointer( stream, self->_valueAt );
	Journal_PrintPointer( stream, self->_getMinGlobalMagnitude );
	Journal_PrintPointer( stream, self->_getMaxGlobalMagnitude );

	Journal_Printf( stream, "Swarm - '%s'\n", self->swarm->name );
	if ( self->variable != NULL )
		Journal_Printf( stream, "Variable - '%s'\n", self->variable->name );

	Journal_PrintValue( stream, self->dofCount );
	Journal_PrintPointer( stream, self->swarmVariable_Register );
	Stream_UnIndent( stream );
}
void TimeIntegrationSuite_TestDriver( TimeIntegrationSuiteData* data, char *_name, char *_DerivName0, char *_DerivName1, int _order ) {
   Stg_ComponentFactory* cf;
   Stream*               stream;
   Dictionary*           dictionary;
   TimeIntegrator*       timeIntegrator;
   TimeIntegrand*        timeIntegrand;
   TimeIntegrand*        timeIntegrandList[2];
   DomainContext*        context;
   Variable*             variable;
   Variable*             variableList[2];
   double*               array;
   double*               array2;
   Index                 size0 = 11;
   Index                 size1 = 7;
   Index                 array_I;
   Index                 timestep = 0;
   Index                 maxTimesteps = 10;
   Bool                  simultaneous;
   unsigned              order;
   double                error = 0.0;
   Name                  derivName;
   double                tolerance = 0.001;
   Index                 integrand_I;
   Index                 integrandCount = 2;
   char                  expected_file[PCU_PATH_MAX];

   dictionary = Dictionary_New();
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"outputPath", Dictionary_Entry_Value_FromString("./output") );
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"DerivName0", Dictionary_Entry_Value_FromString(_DerivName0) );
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"DerivName1", Dictionary_Entry_Value_FromString(_DerivName1) );

   context = DomainContext_New( "context", 0, 0, MPI_COMM_WORLD, NULL );
   cf = stgMainConstruct( dictionary, NULL, data->comm, context );
   stgMainBuildAndInitialise( cf );
      
   ContextEP_Append( context, AbstractContext_EP_Dt, TimeIntegrationSuite_GetDt );

   /* Create Stuff */
   order = _order;
   simultaneous = False;
   variableList[0] = Variable_NewVector( "testVariable", (AbstractContext*)context, Variable_DataType_Double, 2, &size0, NULL, (void**)&array, NULL );
   variableList[1] = Variable_NewVector( "testVariable2", (AbstractContext*)context, Variable_DataType_Double, 2, &size1, NULL, (void**)&array2, NULL );
   timeIntegrator = TimeIntegrator_New( "testTimeIntegrator", order, simultaneous, NULL, NULL );
   timeIntegrator->context = context;
   timeIntegrandList[0] = TimeIntegrand_New( "testTimeIntegrand0", context, timeIntegrator, variableList[0], 0, NULL, True );
   timeIntegrandList[1] = TimeIntegrand_New( "testTimeIntegrand1", context, timeIntegrator, variableList[1], 0, NULL, True );

   Journal_Enable_AllTypedStream( True );
   stream = Journal_Register( Info_Type, (Name)"EulerStream"  );
   Stream_RedirectFile( stream, _name );

   Stream_Enable( timeIntegrator->info, False );
   derivName = Dictionary_GetString( dictionary, (Dictionary_Entry_Key)"DerivName0" );
   timeIntegrandList[0]->_calculateTimeDeriv = TimeIntegrationSuite_GetFunctionPtr( derivName  );
   Journal_Printf( stream, "DerivName0 - %s\n", derivName );
   derivName = Dictionary_GetString( dictionary, (Dictionary_Entry_Key)"DerivName1" );
   timeIntegrandList[1]->_calculateTimeDeriv = TimeIntegrationSuite_GetFunctionPtr( derivName  );
   Journal_Printf( stream, "DerivName1 - %s\n", derivName );

   /* Print Stuff to file */
   Journal_PrintValue( stream, order );
   Journal_PrintBool( stream, simultaneous );

   /* Add stuff to EPs */
   TimeIntegrator_AppendSetupEP( timeIntegrator, "start1", TimeIntegrationSuite_TestContextType, CURR_MODULE_NAME, context );
   TimeIntegrator_AppendFinishEP( timeIntegrator, "finish1", TimeIntegrationSuite_TestVariableType, CURR_MODULE_NAME, variableList[0] );
   TimeIntegrator_PrependSetupEP( timeIntegrator, "start0", TimeIntegrationSuite_TestVariableType, CURR_MODULE_NAME, variableList[0] );
   TimeIntegrator_PrependFinishEP( timeIntegrator, "finish0", TimeIntegrationSuite_TestContextType, CURR_MODULE_NAME, context );

   /* Build */
   Stg_Component_Build( variableList[0], context, False );
   Stg_Component_Build( variableList[1], context, False );
   Stg_Component_Build( timeIntegrator, context, False );
   Stg_Component_Build( timeIntegrandList[0], context, False );
   Stg_Component_Build( timeIntegrandList[1], context, False );
   array = Memory_Alloc_Array( double, 2 * size0, "name" );
   array2 = Memory_Alloc_Array( double, 2 * size1, "name" );

   /* Initialise */
   memset( array, 0, sizeof(double) * 2 * size0 );
   memset( array2, 0, sizeof(double) * 2 * size1 );
   Stg_Component_Initialise( timeIntegrator, context, False );
   Stg_Component_Initialise( variableList[0], context, False );
   Stg_Component_Initialise( variableList[1], context, False );
   Stg_Component_Initialise( timeIntegrandList[0], context, False );
   Stg_Component_Initialise( timeIntegrandList[1], context, False );

   for ( timestep = 0.0 ; timestep < maxTimesteps ; timestep ++ ) {
      Journal_Printf( stream, "Step %u - Time = %.3g\n", timestep, context->currentTime );

      Stg_Component_Execute( timeIntegrator, context, True );
      context->currentTime += AbstractContext_Dt( context );

      for ( integrand_I = 0 ; integrand_I < integrandCount ; integrand_I++ ) {
         timeIntegrand   = timeIntegrandList[ integrand_I ];
         variable         = variableList[ integrand_I ];
         for ( array_I = 0 ; array_I < variable->arraySize ; array_I++ ) {
            if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) - 2.0 * array_I * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) + array_I * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv2 ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) + 0.5 * array_I * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) - 3 * array_I * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) - array_I * context->currentTime * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) + 0.5 * array_I * context->currentTime * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv2 ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) + 0.25 * array_I * context->currentTime * context->currentTime );
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) - 1.5 * array_I * context->currentTime * context->currentTime );
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) - 2.0 * array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0)/3.0));
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) + array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0 )/3.0));
            }
            else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv2 ) {
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 0 ) + 0.5 * array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0)/3.0));
               error += fabs( Variable_GetValueAtDouble( variable, array_I, 1 ) - 3.0 * array_I * ( 0.25 * pow( context->currentTime, 4.0 ) - pow( context->currentTime, 3.0 )/3.0));
            }
            else
               Journal_Firewall( 0 , Journal_Register( Error_Type, (Name)CURR_MODULE_NAME  ), "Don't understand _calculateTimeDeriv = %p\n", timeIntegrand->_calculateTimeDeriv );
         }
      }
   }
   pcu_check_lt( error, tolerance );

   if ( error < tolerance )
      Journal_Printf( stream, "Passed\n" );
   else
      Journal_Printf( stream, "Failed - Error = %lf\n", error );
   
   Journal_Enable_AllTypedStream( False );

   if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv
      || timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_ConstantTimeDeriv2 ) {
      pcu_filename_expected( "testTimeIntegrationEulerOutput.expected", expected_file );
   }
   else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv
      || timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_LinearTimeDeriv2 ) {
      pcu_filename_expected( "testTimeIntegrationRK2Output.expected", expected_file );
   }
   else if ( timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv
      || timeIntegrand->_calculateTimeDeriv == TimeIntegrationSuite_CubicTimeDeriv2 ) {
      pcu_filename_expected( "testTimeIntegrationRK4Output.expected", expected_file );
   }

   pcu_check_fileEq( _name, expected_file );

   /* Destroy stuff */
   Stream_CloseAndFreeFile( stream );
   Memory_Free( array );
   Memory_Free( array2 );
   Stg_Class_Delete( variable );
   _Stg_Component_Delete( timeIntegrator );
   _Stg_Component_Delete( timeIntegrandList[0] );
   _Stg_Component_Delete( timeIntegrandList[1] );
   remove( _name );
}