1// 2// AppDelegate.m 3// PETSc cocoa example 4// 5// Created by Barry Smith on 8/2/12. 6// Copyright (c) 2012 Barry Smith. All rights reserved. 7// 8 9#import "AppDelegate.h" 10#import "PETSc/petsc.h" 11 12 13/* 14 This is called by PETSc for all print calls. 15 16 Need to create a place in Cocoa to put the print messages; commented out code below is from iOS example 17 18 */ 19PetscErrorCode PetscVFPrintfiPhone(FILE *fd,const char *format,va_list Argp) 20{ 21 size_t len; 22 char str[1024]; 23 24 PetscVSNPrintf(str,1024,format,&len,Argp); 25 // globalTextView.text = [NSString stringWithFormat:@"%@%s", globalTextView.text,str]; 26 return 0; 27} 28 29extern PetscErrorCode PetscVFPrintfiPhone(FILE *,const char *,va_list); 30 31@implementation AppDelegate 32 33- (void)dealloc 34{ 35 [super dealloc]; 36} 37 38#define main ex19 39#define PETSC_APPLE_FRAMEWORK 40#include "../../../../../../src/snes/tutorials/ex19.c" 41 42- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 43{ 44 // Insert code here to initialize your application 45 PetscVFPrintf = PetscVFPrintfiPhone; 46 char **args; 47 int argc; 48 49 /* this example is silly because it just runs a PETSc example when the graphics window appears 50 but it does test the use of the PETSc framework */ 51 52 PetscStrToArray("ex19 -ksp_monitor",' ',&argc,&args); 53 ex19(argc,args); 54 55 56} 57 58@end 59