[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trouble with DA, multiple degrees of freedom
- To: petsc-users@xxxxxxxxxxx
- Subject: Re: Trouble with DA, multiple degrees of freedom
- From: "Matthew Knepley" <knepley@xxxxxxxxx>
- Date: Tue, 5 Feb 2008 13:58:58 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=l5cPgsZHv/CT2WJQj0XFBVlJ/aVd+7yHsSjLsHIXLXc=; b=EvRe3IbA9ntQEFKNoTsr8dc0/KeqEu+OjJTxNYnw2K7WtxErbNi9LLIUzcZF1Tnaqhk8HcN86jzhioNBaLm1YJ8BRBl3n8t268gQzIhZ+fcFfM8jLPvaqLjKBoNeykZ1hmguwsLIC4VWFmVoCla+xu+QyHeodWmqoRhuoXSE8X4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=scjBrJ/27zL/fFRJsv/MsHMsGaPFbX9M5K03BReFn+d9QUWlIFsseVJlQ7zCyglusja7JzyK4wFvYIEastG0gtEk8vh2IYC2gkia94EMHv+u5u05jVHpUoO8RQWrfVw5Q5DSjjPR8jZxFU2WmKlbvQu1ILPUdP9r0AtKLZf23GQ=
- In-reply-to: <d91228d00802051150j1b78d612hd8f926893bef5200@mail.gmail.com>
- References: <d91228d00802051150j1b78d612hd8f926893bef5200@mail.gmail.com>
- Reply-to: petsc-users@xxxxxxxxxxx
- Sender: owner-petsc-users@xxxxxxxxxxx
The easiest thing to do in C is to declare a struct:
typedef struct {
PetscScalar v[3];
PetscScalar p;
} Space;
and then cast pointers
Space ***array;
DAVecGetArray(da, u, (void *) &array);
array[k][j][i].v *= -1.0;
Thanks,
Matt
On Feb 5, 2008 1:50 PM, Pearl Flath <pflath@xxxxxxxxxxxxxxx> wrote:
> Dear All,
> I have a code where the velocity (three components) and pressure are all
> stored in a distributed array with 4 degrees of freedom per node. I'd like
> to take one component of the velocity and multiply it by -1, but I am having
> trouble figuring out how to access that. I believe it must involve
> DAVecGetArrayDOF or DAVecGetArray, but I haven't managed to get either to
> work. I've attached a code fragment where it loads the velocity. Could
> someone suggest how to do this or point me to where I can find additional
> discussion of this? I've read the users manual on DA already.
> Sincerely,
> Pearl Flath
> ICES, UT Austin
> ---------------------------------
> DACreate3d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_BOX,m,n,p,
> PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,
> 4,1,PETSC_NULL,PETSC_NULL,PETSC_NULL,&daV);
>
> DACreateGlobalVector(daV, &vel);
>
> // Set the velocity file to read from
> PetscTruth flg ;
> PetscViewer view_u;
> char velocityfile[1024] ;
> PetscOptionsGetString(0,"-velocityfile",velocityfile,1023,&flg);
>
> PetscViewerBinaryOpen(PETSC_COMM_WORLD, velocityfile,
> FILE_MODE_READ, &view_u);
> VecLoadIntoVector(view_u, vel);
> PetscViewerDestroy(view_u);
>
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener