C and cpp file

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
pejman_opensees
Posts: 123
Joined: Tue Oct 31, 2006 10:40 am
Location: k.n.toosi University

C and cpp file

Post by pejman_opensees »

Dear Frank,

There are both c and cpp files in \PACKAGES\win32 when I go through WindowsDLLs.sln. That is, I found trussC.c as well as TrussCPP.cpp. Are they related somehow? If I want to make changes to trussCpp and build my own element and/or material, Do I have to make my changes to both of them or just cpp file?
Thanks
Pejman
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

depends if you want to program in c or c++. they are the same example, just one in c and the other in c++
amir70007
Posts: 58
Joined: Sat Sep 20, 2008 11:13 pm
Location: Tehran-Amir Kabir University of Technology (Tehran Polytechnic)
Contact:

Re: C and cpp file

Post by amir70007 »

Hi All

I have a question about *.h and *.cpp files.
How can I use these files in Opensees commands?

Best,
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: C and cpp file

Post by fmk »

what are you asking? .. rephrase the question
evgin
Posts: 64
Joined: Tue Dec 06, 2011 3:18 pm
Location: UCLA

Question

Post by evgin »

Hi Frank,

The following tcl script I wrote gets me an error , would you please check it out and let me know what is the problem if possible?



#---SOIL GEOMETRY
# thicknesses of soil profile (m)

set soilThick 30.0

# number of soil layers

set numLayers 3

# layer thicknesses

set layerThick(3) 2.0

set layerThick(2) 8.0

set layerThick(1) 20.0

# depth of water table

set waterTable 2.0

# define layer boundaries

set layerBound(1) $layerThick(1)

set sum $layerBound(1)

for {set i 2} {$i<=$numLayers} {incr i 1} {

set sum [expr $sum+$layerThick($i)]

set layerBound($i) $sum

}

#---MESH GEOMETRY

# number of elements in horizontal direction

set nElemX 1

# number of nodes in horizontal direction

set nNodeX [expr 2*$nElemX+1]

# horizontal element size (m)

set sElemX 2.0

# number of elements in vertical direction for each layer

set nElemY(3) 4

set nElemY(2) 16

set nElemY(1) 40

# total number of elements in vertical direction

set nElemT 60

# vertical element size in each layer

for {set i 1} {$i <=$numLayers} {incr i 1} {

set sElemY($i) [expr $layerThick($i)/$nElemY($i)]

puts "size: $sElemY($i)"
}

# number of nodes in vertical direction

set nNodeY [expr 2*$nElemT+1]

# total number of nodes

set nNodeT [expr $nNodeX*$nNodeY]


################# creating interiror nodes #################


model BasicBuilder -ndm 2 -ndf 2

set x1coord [expr $sElemX/2]

set x2coord $sElemX

set k 1


set nodelist {}


set lowerBound 0


for {set j 1} {$j<= $nNodeY} {incr j 1} {


if {[expr ($j-1)*$sElemY($k)/2]<=$layerBound($k) && [expr ($j-1)*$sElemY($k)/2]> $lowerBound} {


set ycoord [expr ($j-1)*$sElemY($k)/2]


lappend nodelist $ycoord

return $nodelist


} else {

set k [expr $k+1]

if {$k>3} {

set k 3


}

}

set lowerBound $layerBound($k)


}


for {set i 2} {$i <= $nNodeY} {incr i 3} {


set k 2

set ycoor [lindex $nodelist [expr $i-$k]]

node $i $x1coord $ycoor

set k [expr $k+2]

}


for {set i 1} {$i <= [expr $nNodeY-$nElemT]} {incr i 6} {


set k 0

set ycoor [lindex $nodelist [expr $i-$k]]

node $i 0 $ycoor

node [expr $i+2] $x2coord $ycoor


set k [expr $k+4]

}
flintop12
Posts: 3
Joined: Mon Dec 26, 2011 8:39 am

Re: C and cpp file

Post by flintop12 »

c and c++ both language is same but in this language the coding is different because both programming is diifferent extence so I think we use one program in both extence but the file save is different name with extence c and cpp.both language programs are same but in this program we print the value in different name. like in c "println", "scanf".
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: C and cpp file

Post by fmk »

i presume you have already determined that ycoor around line 136 was not set correctly
evgin
Posts: 64
Joined: Tue Dec 06, 2011 3:18 pm
Location: UCLA

Re: C and cpp file

Post by evgin »

Hi Frank,

When I try to run the following script which is a part of a bigger one , OpenSees analysis window freezes and I have to close it. I have tried to play with it and I found that there is something wrong with the TransfTag assignment.

The program is to assign a LinearBeamColumn element to the bridge spine line beam in the longitudinal direction.

Could anybody help me , I have spent hours to detect the error but no success.

Thanks,
Evgin.


# geomTransf Linear $transfTag $vecxzX $vecxzY $vecxzZ <-jntOffset $dXi $dYi $dZi $dXj $dYj $dZj>

set IDColTrans 1

set IDSpineBeam 2

set IDCapBeamTrans 3

# supperstructure spine-line ( figure 2.1 AVIRAM)

geomTransf Linear $IDSpineBeam 0 0 1

# cap beams

geomTransf Linear $IDCapBeamTrans 0 0 1

# column

geomTransf Linear $IDColTrans 0 1 0

# creating spine-line element for the supper structure

set count 1

for {set i 100} {$i <120} {incr i 1} {

set eleID [expr 2*$i-($count-1)]

set nID $i

set nJD [expr $i+1]


#element elasticBeamColumn $eleTag $iNode $jNode $A $E $G $J $Iy $Iz $transfTag <-mass $massDens>

element elasticBeamColumn $eleID $nID $nJD $areabeam $ec $gc $j $ix $iz $IDSpineBeam

set count [expr $count+1]

}
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: C and cpp file

Post by fmk »

sorry for the delay .. i trust you figured this out
Post Reply