Changeset 202 for trunk/src/mesh


Ignore:
Timestamp:
Feb 20, 2006 8:47:50 PM (18 years ago)
Author:
cxsong
Message:

additions to makefile, error codes, changes to element.

Location:
trunk/src/mesh
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mesh/Makefile

    r185 r202  
    2222# replace this with the full path of the directory
    2323# containing the rappture directory
    24 TOP_DIR         = ../..
     24TOP_DIR         = /home/cxsong
    2525
    2626# define the top of the rappture directory structure
     
    6060LIB_RP_OBJECTS  = $(LIB_INC_PREFIX) -lRpObjects
    6161LIB_RAPPTURE    = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture
     62LIB_RPMESH      = -Wl,-rpath,$(LIB_DIR) -L/$(LIB_DIR) -lrpmesh
    6263
    6364INCL_CORE       = -I$(INCLUDES_DIR)/core
     
    8283                  RpChoice.o RpOption.o RpUnitsStd.o RpUnits.o #RpValue.o\
    8384                  # RpValueDouble.o RpValueString.o
    84 RP_MESH_DEPS = util.o grid1d.o grid1d_reg.o grid2d.o #mesh.o field.o endian.o
     85RP_MESH_DEPS = element.o util.o grid1d.o grid1d_reg.o grid2d.o node3d.o node2d.o #mesh.o field.o endian.o
    8586
    8687LDLIB_MACOSX = -dynamiclib -o $(LIB_DIR)/$@.dylib
     
    9394
    9495librpmesh: $(RP_MESH_DEPS)
     96        if test "`uname`" == "Darwin"; then \
     97                $(CXX) $(DEGUG) $(LDLIB_MACOSX) $^ $(LIB_SCEW_FLAG) -lm; \
     98                ar -r $@.a $^; \
     99                ranlib -s $@.a; \
     100        else \
     101                $(CXX) $(DEGUG) $(LDLIB_LINUX) $^; \
     102                /sbin/ldconfig -n $(LIB_DIR); \
     103                ar -r $@.a $^; \
     104                ranlib $@.a; \
     105        fi
     106librappture: $(RP_IO_DEPS) $(RP_UNITS_DEPS) $(RP_OTHER_DEPS)
    95107        if test "`uname`" == "Darwin"; then \
    96108                $(CXX) $(DEGUG) $(LDLIB_MACOSX) $^ $(LIB_SCEW_FLAG) -lm; \
     
    103115                ranlib $@.a; \
    104116        fi
    105 librappture: $(RP_IO_DEPS) $(RP_UNITS_DEPS) $(RP_OTHER_DEPS)
    106         if test "`uname`" == "Darwin"; then \
    107                 $(CXX) $(DEGUG) $(LDLIB_MACOSX) $^ $(LIB_SCEW_FLAG) -lm; \
    108                 ar -r $@.a $^; \
    109                 ranlib -s $@.a; \
    110         else \
    111                 $(CXX) $(DEGUG) $(LDLIB_LINUX) $^ $(LIB_SCEW_FLAG) -lm; \
    112                 /sbin/ldconfig -n $(LIB_DIR); \
    113                 ar -r $@.a $^; \
    114                 ranlib $@.a; \
    115         fi
    116117
    117118install_rappture: librappture
     
    174175util.o: util.cc
    175176        $(CXX) $(CFLAGS) $(DEBUG) -c $?
     177node2d.o: node2d.cc
     178        $(CXX) $(CFLAGS) $(DEBUG) -c $?
     179node3d.o: node3d.cc
     180        $(CXX) $(CFLAGS) $(DEBUG) -c $?
    176181endian.o: endian.cc
     182        $(CXX) $(CFLAGS) $(DEBUG) -c $?
     183element.o: element.cc
    177184        $(CXX) $(CFLAGS) $(DEBUG) -c $?
    178185
     
    344351
    345352#################
     353
    346354endiantest: endiantest.o
    347355        $(CXX) -o $@ $<
     356test_node: test_node.o
     357        $(CXX) -o $@ $< $(LIB_RPMESH)
  • trunk/src/mesh/element.h

    r194 r202  
    44#include <iostream>
    55#include <vector>
    6 #include "node.h"
     6#include "node3d.h"
    77#include "util.h"
    88
     
    1111// in a mesh.
    1212//
    13 // Example:
    14 //      int nodeIDs[8];
    15 //      RpElement elements[10];
    16 //
    17 //      // set ids for all elements
    18 //      for (int i=0; i<10; i++)
    19 //              elements[i].id(i);
    20 //
    21 //      // create node list for element 0
    22 //      nodeIDs[0] = 0;
    23 //      nodeIDs[1] = 1;
    24 //      nodeIDs[2] = 5;
    25 //      nodeIDs[3] = 6;
    26 //      nodeIDs[4] = 25;
    27 //      nodeIDs[5] = 26;
    28 //      nodeIDs[6] = 30;
    29 //      nodeIDs[7] = 31;
    30 //      element[0].addNodes(nodeIDs, 8);
    31 //
    32 //      nodeIDs[0] = 1;
    33 //      nodeIDs[1] = 2;
    34 //      nodeIDs[2] = 6;
    35 //      nodeIDs[3] = 7;
    36 //      nodeIDs[4] = 26;
    37 //      nodeIDs[5] = 27;
    38 //      nodeIDs[6] = 31;
    39 //      nodeIDs[7] = 32;
    40 //      element[1].addNodes(nodeIDs, 8);
    41 //
    42 //      ...
    43 //
    44 //
    45 
    4613class RpElement {
    4714public:
     
    5017        {
    5118                // default
    52                 m_nodes(8);
     19                m_nodes.resize(10);
    5320        };
    5421
     
    5623        {
    5724                m_id = id;
    58                 if (m_nodes.capacity() < numNodes)
     25                if (m_nodes.capacity() < (unsigned)numNodes)
    5926                        m_nodes.resize(numNodes);
    6027        };
    6128
    6229        // instantiate from byte stream:
    63         // id(int), numNodes(int), list of ids(int *)
     30        // id(int), numNodes(int), list of node ids(int *)
    6431        RpElement(const char* buf);
    6532
     
    7138       
    7239        // get node id's
    73         RP_ERROR getNodeIdList(int* list, int len);
     40        RP_ERROR getNodeIdList(int* list, int& len);
    7441
    7542        int id() { return m_id; };
    7643        void id(int id) { m_id = id; };
    7744
     45
     46        // serialize
     47        // id(int), numNodes(int), list of ids(int *)
    7848        char* serialize();
    79         void serialize(const char* buf, int buflen);
    80         void deserialize(const char* buf);
     49        RP_ERROR serialize(char* buf, int buflen);
     50        RP_ERROR deserialize(const char* buf);
    8151
    8252        void print();
     
    9161        int m_id;
    9262        vector<int> m_nodes; // list of node ids
     63
     64        // total number of bytes in an element:
     65        //     bytes for all node ids + element id + numberOfNodes
     66        int numBytes() {
     67                return ((m_nodes.size()) * sizeof(int) + 2*sizeof(int));
     68        };
    9369};
    9470
  • trunk/src/mesh/node2d.h

    r198 r202  
    3131        { xval = m_x; yval = m_y; };
    3232
    33         void get(int * val) { val[0] = m_x; val[1] = m_y; );
     33        void get(int * val) { val[0] = m_x; val[1] = m_y; };
    3434
    3535        int id() { return m_id; };
  • trunk/src/mesh/util.cc

    r186 r202  
    1 #include "rp_defs.h"
     1#include "util.h"
    22
    33string RpErrorStr;
  • trunk/src/mesh/util.h

    r186 r202  
    2020};
    2121
    22 enum RP_ERROR_CODES {
     22enum RP_ERROR {
    2323        RP_SUCCESS,
     24        RP_FAILURE,
    2425        RP_ERR_MEM_ALLOC,
    2526        RP_ERR_NULL_PTR,
    26         RP_ERR_TIMEOUT
     27        RP_ERR_TIMEOUT,
     28        RP_ERR_OUTOFBOUND_INDEX,
     29        RP_ERR_INVALID_ARRAY
    2730};
    2831
Note: See TracChangeset for help on using the changeset viewer.