Welcome, Guest
Username: Password: Remember me

TOPIC: Calling different mesh zones to assign head losses

Calling different mesh zones to assign head losses 6 years 8 months ago #29342

  • SDAC
  • SDAC's Avatar
Hello,

Is there a way to reference specific zones of a mesh in the fortran file?

I have a mesh with many discrete zones which represent roughness elements with different surface areas. I want to assign head losses at the layers in these zones. I implemented these zones by mapping all the zone polygons onto the mesh in blue kenue, and saved this mesh as a private variable. Currently my code follows:

- find the nodes on which to apply head losses using the private variable (i.e.find all the zones)
- find the layers I want to apply head losses to (i.e. find layers in the zones above a certain height)
- identify the 3D node ID
- identify each zone ID
- state average surface area for this zone

Something like:

DO I=1,NPOIN2 IF (PRIVE2D%ADR(1)%P%R(I).GT.0.1D0)THEN DO IPLAN = NPLAN-29,NPLAN I3D = I+NPOIN2*(IPLAN-1) IF !!!ZONE_ID = ??!!! THEN AREA = n ELSE IF = !!!ZONE_ID = ?? THEN AREA = n2 /code] Creating a private variable for each zone would require too many for Telemac (which has a max of 4), and would result in a large number of meshes which would take up memory/be cumbersome. If each polygon I use to define a zone has a different value (such as you would do for defining different friction coefficients) is it possible to call this value to identify an individual zone, and so apply the local surface area to the head losses at the nodes in this zone? Or is there another solution? Many thanks![code] DO I=1,NPOIN2
IF (PRIVE2D%ADR(1)%P%R(I).GT.0.1D0)THEN
DO IPLAN = NPLAN-29,NPLAN
I3D = I+NPOIN2*(IPLAN-1)
IF !!!ZONE_ID = ??!!! THEN
AREA = n
ELSE IF = !!!ZONE_ID = ?? THEN
AREA = n2
/code]

Creating a private variable for each zone would require too many for Telemac (which has a max of 4), and would result in a large number of meshes which would take up memory/be cumbersome.

If each polygon I use to define a zone has a different value (such as you would do for defining different friction coefficients) is it possible to call this value to identify an individual zone, and so apply the local surface area to the head losses at the nodes in this zone?

Or is there another solution?

Many thanks!
The administrator has disabled public write access.

Calling different mesh zones to assign head losses 6 years 7 months ago #29459

  • riadh
  • riadh's Avatar
Hello

Sorry for this late reply, I've just read your post.
Did you fix your issue?
I think your idea could work nicely. You can identify your zones using different vlaues as you have written in your code. It will lead to the same strategy than friction zones.
If you need more helps please let me know.
with my kind regards

Riadh
The administrator has disabled public write access.

Calling different mesh zones to assign head losses 6 years 7 months ago #29465

  • SDAC
  • SDAC's Avatar
Hi Riadh,

Thanks for your reply.

I didn't find a solution for the above question, however at the moment I'm using all four private variables which is fine for my work. If I need a fifth later I will need to re-think a)can I try and implement more private variables, or b) find a way to identify zones of roughness elements using the values written in my code.


So far it's going well!

Many thanks.
The administrator has disabled public write access.

Calling different mesh zones to assign head losses 6 years 7 months ago #29487

  • SDAC
  • SDAC's Avatar
I have a question:

I want to include a coefficient R in my drag parameterisation. R changes with each roughness zone. I need to solve the drag equation on all the nodes for each roughness zone using the R local to each zone.

I am thinking of placing all my roughness zones onto one private variable. Then find the value for each zone in that variable. When Telemac reads a node with a certain value, then a specific R value is applied to the drag equation for that node.

For example, using private variable containing the different zones:
DO I=1,NPOIN2
	 IF (PRIVE2D%ADR(2)%P%R(I).GT.0.1D0)THEN !Find zones
   			DO IPLAN = NPLAN-33,NPLAN-30 !find layers
				I3D = I+NPOIN2*(IPLAN-1) !find nodes
                                R = 0.55                 !define R
	 IF (PRIVE2D%ADR(2)%P%R(I).GT.0.2D0)THEN 
   			DO IPLAN = NPLAN-33,NPLAN-30
				I3D = I+NPOIN2*(IPLAN-1)
                                R = 0.46
	 IF (PRIVE2D%ADR(2)%P%R(I).GT.0.3D0)THEN 
   			DO IPLAN = NPLAN-33,NPLAN-30
				I3D = I+NPOIN2*(IPLAN-1)
                                R = 0.41
NORM =SQRT(UN3%R(I3D)**2+VN3%R(I3D)**2+WN3%R(I3D)**2)
			S1U%R(I3D)=0.5D0*AREA*R*CD*NORM !apply R
			S1V%R(I3D)=0.5D0*AREA*R*CD*NORM
			S1W%R(I3D)=0.5D0*AREA*R*CD*NORM 
Would this be appropriate?

Many thanks!
The administrator has disabled public write access.

Calling different mesh zones to assign head losses 6 years 7 months ago #29492

  • pilou1253
  • pilou1253's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 584
  • Thank you received: 106
Hi,

I jump into this discussion as I often use private variables to do such treatments.

First, your example is wrong since you miss the DO IPLAN: 1,NPLAN loop to convert from 2D to 3D mesh.

Then, beware because a value of PRIVE2D%ADR(2)%P%R(I) = 1.0 stored in your mesh would result in R = 0.55 (GT. 0.1) since your IF tests are not bounded.

Good luck!

Best regards
PL
The administrator has disabled public write access.
The following user(s) said Thank You: SDAC

Calling different mesh zones to assign head losses 6 years 7 months ago #29498

  • SDAC
  • SDAC's Avatar
Thanks for pointing that out!

Quick question about (GT.0.1) - had assumed that just pointed towards whatever value I had assigned the nodes in each zone. e.g. the code applies an argument to the nodes in PRIVE2D%ADR(2) where the node values = 1. But from what you say there's more to it than that? Could you please explain a little of the function of GT if so?

Many thanks.
The administrator has disabled public write access.

Calling different mesh zones to assign head losses 6 years 7 months ago #29566

  • SDAC
  • SDAC's Avatar
Hello again,

Quick question on Private Variables - how is the order of the private arrays determined? For example, is it by their organisation in the geometry file, the order by which they're named in the .cas file?

i.e. how can I be sure that PRIVE%ADR(2)%P matches the appropriate array?

Thanks!
The administrator has disabled public write access.

Calling different mesh zones to assign head losses 6 years 7 months ago #29610

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi
In the principle, your code seems ok but...

The main problem is probably located in the test you do.
Your test implicitly suppose the equality between double precision values...
When you create your value on the mesh, you give a real value which is a simple precision value. In telemac, there is a conversion from simple to double which could leads to small differences and then the test is never valid...
You could check this by adding a write inside the test.

More generally, your code is really bad from an optimization point of view...
You have 3 times the main loop on all 2D nodes.
You could rewrite it to only have 1 loop and just manage the choice of the area according to the test on PRIVE2.

And maybe more simple, put in prive2 the value of AREA instead of 2, 3 or 4 and use prive2 instead of AREA...

Kind regards
Christophe
The administrator has disabled public write access.
The following user(s) said Thank You: SDAC

Calling different mesh zones to assign head losses 6 years 7 months ago #29611

  • SDAC
  • SDAC's Avatar
Thankyou for the advice!

To avoid conversion errors I'll input all data as double precision format.

I'm concerned that the head losses aren't implemented in 3D appropriately. Even if the differences between values are small, the doesn't seem to be any change between normal flow and flow with roughness elements.

In most code I've seen the loop begins with DO IPLAN = 1,NPLAN for 3D. My code defines IPLAN in the IF loop for PRIVE2D. Should the DO IPLAN = 1,NPLAN always be stated at the beginning? If I do, then I have problems defining the IPLAN when stating which layers to prescribe the head losses.

Many thanks!
The administrator has disabled public write access.

Calling different mesh zones to assign head losses 6 years 7 months ago #29609

  • SDAC
  • SDAC's Avatar
I'm testing the code below, however the results don't seem to showing the impact on the flow as expected - it looks similar to my calibrated flow. I'm experimenting with my roughness coefficient. However, I'm concerned that the below isn't implemented. Are there any major problems?

I'm including three types of roughness elements in my channel, each with a different area. Each type is assigned a value (2,3, or 4) which has been prescribed to the nodes of interest in PRIVE2D%ADR(2). My code then assigns the relevant area value to the drag equation at the nodes at the free surface to the fifth layer above the bottom.
DO I=1,NPOIN2 !for all nodes
	IF (PRIVE2D%ADR(2)%P%R(I).EQ.2D0)THEN !where nodes have a value = 2
   			DO IPLAN = NPLAN-29,NPLAN !for layers -29 to free surface
				I3D = I+NPOIN2*(IPLAN-1) !use these node IDs
			     AREA = 24.3816 !use this area			
			
	 NORM =SQRT(UN3%R(I3D)**2+VN3%R(I3D)**2+WN3%R(I3D)**2) !use this equation
			S1U%R(I3D)=0.5D0*AREA*CD2*NORM
			S1V%R(I3D)=0.5D0*AREA*CD2*NORM
			S1W%R(I3D)=0.5D0*AREA*CD2*NORM
			END DO
			END IF
			END DO
	DO I=1,NPOIN2
	IF (PRIVE2D%ADR(2)%P%R(I).EQ.3D0)THEN 
   			DO IPLAN = NPLAN-29,NPLAN
				I3D = I+NPOIN2*(IPLAN-1)
			     AREA = 77.6668			
			
	 NORM =SQRT(UN3%R(I3D)**2+VN3%R(I3D)**2+WN3%R(I3D)**2)
			S1U%R(I3D)=0.5D0*AREA*CD2*NORM
			S1V%R(I3D)=0.5D0*AREA*CD2*NORM
			S1W%R(I3D)=0.5D0*AREA*CD2*NORM
			END DO
			END IF
			END DO

	DO I=1,NPOIN2
	IF (PRIVE2D%ADR(2)%P%R(I).EQ.4D0)THEN 
   			DO IPLAN = NPLAN-29,NPLAN
				I3D = I+NPOIN2*(IPLAN-1)
			     AREA = 27			
			
	 NORM =SQRT(UN3%R(I3D)**2+VN3%R(I3D)**2+WN3%R(I3D)**2)
			S1U%R(I3D)=0.5D0*AREA*CD2*NORM
			S1V%R(I3D)=0.5D0*AREA*CD2*NORM
			S1W%R(I3D)=0.5D0*AREA*CD2*NORM
			END DO
			END IF
			END DO
The administrator has disabled public write access.
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.