CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Trying to integrate using snGrad(). Need some help

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Display Modes
Old   November 18, 2013, 12:12
Exclamation Trying to integrate using snGrad(). Need some help
  #1
New Member
 
Terry
Join Date: May 2013
Posts: 9
Rep Power: 4
MechBoom is on a distinguished road
I am in desperate need of some help with a bit of code I'm trying to implement. I know what I need to do but so far I've been unable to code it properly! I've been struggling with this for almost 3 weeks now to no avail!!

So, here's my problem. I'm trying to find the corona current surrounding a wire in a duct. To do this I need to integrate over the surface of the wire. Inside of this integral I also need the surface normal vector of the E-field. Here's the code I have so far:

Code:
    
60    volVectorField E("E",-fvc::grad(phi)); //Solve For E-Field//
61    
62    //Calculating the Corona Current
63    
64    label patchID = mesh.boundaryMesh().findPatchID("wire"); 
65    const polyPatch& cPatch = mesh.boundaryMesh()[patchID];
66    const surfaceScalarField dl = mesh.magSf();
67        
68    scalar coronaI = 0.0;    
69    forAll (cPatch, i)
70   {
71    coronaI += -rho*k*snGrad(E)[i]*dl.boundaryField()[patchID][i];
72    }
This code is inside the electrostaticFoam solver, this is the solver I'm modifying for my problem. Here is the current error I'm encountering:
Code:
Tester.C:71:44: error: no match for ‘operator[]’ in ‘Foam::fvc::snGrad(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::Vector<double>]()[i]’
I know that I'm not properly calling the snGrad() function but, I don't know how to do it the right way! I'm thinking that the coronaI needs to be a dimensioned scalar too, but who knows!! I'm so very frustrated with this problem right now.

This is a 2D problem by the way. So the magSf() should return my differential length of each cell.

Any help is very appreciated and much needed!!

Last edited by MechBoom; November 18, 2013 at 18:26. Reason: more info
MechBoom is offline   Reply With Quote

Old   November 18, 2013, 15:50
Exclamation Trying to integrate using snGrad(). Need some help
  #2
Senior Member
 
Bernhard Linseisen
Join Date: May 2010
Location: Magdeburg/Geneva
Posts: 178
Blog Entries: 1
Rep Power: 7
Linse is on a distinguished road
Dear Terry,

1.) Could you please try to change the name of your thread to something more narrative about the problem? Ideally what solver you are modifying? Unfortunately by now many people ignore threads of which the name doesn't clearly state the problem.

2.) Could you please attach the error logs you received concerning the compilation of the code? "wmake code.C &> log.error" should do the trick...

3.) Unfortunately I do not know the coding in OF well enough for such questions...

Regards,
Bernhard
Linse is offline   Reply With Quote

Old   November 18, 2013, 18:19
Default
  #3
New Member
 
Terry
Join Date: May 2013
Posts: 9
Rep Power: 4
MechBoom is on a distinguished road
Bernhard,

Thanks for your help, I've edited the post but I can't seem to change the visible title in the forum, so I just started a new thread. Hopefully, that's ok. I don't want to clog up the forum with uneeded posts!
MechBoom is offline   Reply With Quote

Old   November 19, 2013, 18:01
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,318
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings to all!

@MechBoom:
Quote:
Originally Posted by MechBoom View Post
Thanks for your help, I've edited the post but I can't seem to change the visible title in the forum, so I just started a new thread. Hopefully, that's ok. I don't want to clog up the forum with uneeded posts!
If you check the forum rules - http://www.cfd-online.com/Forums/misc.php?do=showrules - you'll find this one:
Quote:
6. Do not post the same message in more than one forum. If your message could be posted in several forums please pick the most relevant forum and post the message only there. If you have posted your question in the wrong place please contact a Forum Moderator to have it moved.
I've removed the excess posts/threads and moved the original one to the programming sub-forum.


As for the original question, a few quick suggestions:
Best regards,
Bruno
Tobi likes this.
wyldckat is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
advanced function with snGrad Ingenierias2003 OpenFOAM 0 July 21, 2011 09:29
the integrate filter paraView bruxellois OpenFOAM 0 October 3, 2010 18:08
Integrate Variables using PAraFoam nandiganavishal OpenFOAM Post-Processing 2 April 17, 2009 12:38
how to integrate the velocity profile Dejara CD-adapco 3 June 26, 2006 00:34


All times are GMT -4. The time now is 18:54.