# orientationi & Sf[facei] - magneticFoam

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 2, 2012, 09:35 orientationi & Sf[facei] - magneticFoam #1 Member   Martin Join Date: Dec 2011 Location: Latvia Posts: 54 Rep Power: 6 Greetings! I have spent a lot of time in doing all kinds of manipulations with magneticFoam and finally I have almost come to the end. There is only one totally unclear line for me in createFields.H Code: ```const surfaceVectorField& Sf = mesh.Sf(); Mrf[facei] = Mri*(orientationi & Sf[facei]);``` I guess my problem is more about C language not about magnetic field physics. My questions: What should I get out when these lines are compiled? I get surfaceScalarField in output, but shouldn't there be VectorField? What the first line defines, where information about this mesh.Sf will be taken from? Mri is a constant, what should happen when I multiply a constant with those parameters in brackets? Also, there is orientation (that is some kind of vector) and then there is '&' symbol. Does it mean Mri is multiplied with orientationi and Sf[facei] in the same time? Yours sincerely, Martin

 April 2, 2012, 10:05 #2 Member   Björn Windén Join Date: Feb 2012 Location: University of Southampton UK Posts: 37 Rep Power: 6 Hi Martin. It is correct that you get a scalar if orientationi is a vector. the "&" means inner product, (vector & vector) gives a scalar inside the brackets which are then multiplied using scalar multiplication (*) with another scalar Mri. As for Sf. The first line defines a new vectorfield Sf which is given the values of the face area normals of the mesh. //Björn

 April 2, 2012, 13:30 #3 Member   Martin Join Date: Dec 2011 Location: Latvia Posts: 54 Rep Power: 6 Thank you so much. It actually finally starts to make sense. Sad my C skills aren't so good yet to understand this by myself. About face area - so I have defined all faces in a volume. That means if normals are taken and my mesh consists of tetrahedrons then from one cell I get 4 faces and every face would have its normal in different direction? What should (and is that even possible?) I change so that output stays the same surfaceScalarField when I multiply orientation with something else? I mean, I want to use my tetrahedrons as volume elements, but now it seems their face normal orientation is the problem. Martin

 April 3, 2012, 12:07 #4 Member   Björn Windén Join Date: Feb 2012 Location: University of Southampton UK Posts: 37 Rep Power: 6 Hi. Not sure what the problem with the face normals is. If you post the expression you are trying to replicate, maybe we can figure out how to write it. //Björn

April 3, 2012, 19:24
#5
Member

Martin
Join Date: Dec 2011
Location: Latvia
Posts: 54
Rep Power: 6
I'll try to explain as best I can.

At first here is full source code: http://foam.sourceforge.net/docs/cpp/a03265_source.html

As I understand then this solver is capable of solving a magnetic field only if there are defined faces of magnet, it doesn't take in calculation the volume of magnet (because of usage of faces/surfaceFields). Still I somehow managed to include a volume of a bar magnet using topoSet. From what you said I guess I included all faces in this volume.

I added picture how my bar looks like. Its volume is filled with tetrahedrons. When solver defines your mentioned Sf field, as I can understand, it then takes every face inside this volume and draws a normal from it. And here comes the problem.

The mentioned constant Mrf is now multiplied with this normal. It is a small number, lets say it is 0.6 for some iron alloys (more info http://hyperphysics.phy-astr.gsu.edu...s/magperm.html).

So using transportPropoerties I define these constants. Permeability (the first constant of material) is read almost correctly, but when it comes to Mrf (remanence)... uhh. For example, I put Mrf as 0.6, but if I check if solver has kept this value (by using Mrf.write command), then it hasn't. Below I little copy-paste from file (that is what is written as Mrf in magnet):

PHP Code:
``` -9.1199e-141.9816e-132.94547e-13-1.79337e-121.92839e-14  ```
So I find this wrong because of surface normals that are in different directions (and I believe also different length) in volume.

My question then - is there a possible workaround? I need to see the magnetic field inside this magnet bar so I need to define properties of a material in all volume.

Oh, and there is another important thing. The calculations are done by using scalar potential - psi. I define it on the boundaries (magnet poles), for example 100 and -100. After the calculations are done, these values become higher, for example 130 and -120. Shouldn't this defined 'maximum' stay? What could be the cause of rising of psi value.

I hope I explained my problem.

Sincerely,
Martin
Attached Images
 Screenshot at 2012-04-04 01:51:33.jpg (53.9 KB, 17 views)

 April 4, 2012, 05:18 #6 Member   Björn Windén Join Date: Feb 2012 Location: University of Southampton UK Posts: 37 Rep Power: 6 Hi. Code: `Mrf[facei] = Mri*(orientationi & Sf[facei]);` This sets the value of Mrf only on the faces included in the faceZone as found by Code: `label magnetZonei = mesh.faceZones().findZoneID(magnets[i].name());` And not every face in the mesh. As for the values of Mrf: don't you mean that you put Mri to 0.6, this seems to be read from somewhere and then Mrf is calculated based on that value, the orientation and area of each face and the orientation of the magnet. I'm sorry I can't really help you with any magnet-related problems since I don't know anything about it. //Björn

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post latvietis OpenFOAM 37 February 9, 2016 09:04 maddalena OpenFOAM 3 July 12, 2013 16:42 goodkid OpenFOAM 4 December 24, 2011 09:25

All times are GMT -4. The time now is 16:25.

 Contact Us - CFD Online - Top