Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/dbukenberger/HexahedralLattice
20 November 2024, 08:15:20 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • dec04bd
  • /
  • runExamples.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:a4dc3926eb6c12f77831a0882b5252b5e587a9bf
origin badgedirectory badge Iframe embedding
swh:1:dir:dec04bd62de6ca0b3abc19ae3d00a74dbe9177e4
origin badgerevision badge
swh:1:rev:991ca6893ac1feec28f491429111e0fbdcefccc0
origin badgesnapshot badge
swh:1:snp:2df996fe5f309874504f9e2eaff26085dad17e10

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 991ca6893ac1feec28f491429111e0fbdcefccc0 authored by dbukenberger on 20 November 2024, 07:08:57 UTC
Update requirements.txt
Tip revision: 991ca68
runExamples.py
from FemObject import *
from CubeObject import *


if __name__ == '__main__':

    # volume fraction, default is 0.5
    alpha = 0.5

    # show intermediate results
    showResults = False

    # also evaluate materialized tri/tet inputs
    evalInput =  False

    # examples included in the paper
    objNames = ['cube', 'femur', 'fertility', 'kitten', 'spot', 'venus']
    #objNames = ['JEB', 'buddhaDown', 'buddhaBack', 'buddhaBelly']

    # uncomment to compute only 2D examples (quicker)
    #objNames = ['spot2D', 'bunny2D', 'bar2D']

    res = [['object', 'type', 'method', 'nVerts', 'nCells', 'v/v0', 'c/c0', 'ASJ', 'MSJ']]  
    for objName in objNames:
        # setup input FEM object and apply loads
        fInObj = FemObject('data/%s.frc'%objName, False)
        c0 = fInObj.computeCompliance()
        res.append([objName, fInObj.mTypeInit, None, fInObj.nVerts, fInObj.nElems, 1, 1])

        # write stress file
        fInObj.exportToStress()

        # show applied forces
        if showResults:
            fInObj.showForces()

        # materialize input and evaluate
        if evalInput:
            fInObj.materialize(alpha, False)
            c1 = fInObj.computeCompliance(complianceOnly = True)
            res.append([objName, fInObj.mTypeInit+'_b', False, fInObj.nVerts, fInObj.nElems, fInObj.vol / fInObj.volInit, c1 / c0])

            if fInObj.nDim == 3:
                fInObj = FemObject('data/%s.frc'%objName, False)
                c0 = fInObj.computeCompliance()
                fInObj.materialize(alpha, True)
                c1 = fInObj.computeCompliance(complianceOnly = True)
                res.append([objName, fInObj.mTypeInit+'_w', False, fInObj.nVerts, fInObj.nElems, fInObj.vol / fInObj.volInit, c1 / c0])

        # setup cubification object and optimize
        cfgParams = ConfigParams.fromFile('data/%s.cfg'%objName)
        cObj = CubeObject(cfgParams)
        cObj.optimize()
        cObj.saveState()

        # show deformation
        if showResults:
            cVis = CubeVisual()
            cVis.showPlot(cObj)

        #cObj.loadState()
        cObj.fillGrid()
        cObj.padHull()
        cObj.restoreInitShape()

        # show the optimized deformation
        if showResults:
            cObj.evalAlignment()
            cObj.show(False, False)
            mlab.show()

        # export result lattice
        cObj.exportCellsToMesh()

        # load the aligned structure as FEM input
        fResObj = FemObject('data/%s.frc'%objName, True)
        c1 = fResObj.computeCompliance(complianceOnly = True)
        SJs = fResObj.evalScaledJacobians(False)
        res.append([objName, fResObj.mTypeInit, None, len(cObj.gVerts), len(cObj.cells), fResObj.volInit / fInObj.volInit, c1 / c0, SJs.mean(), SJs.min()])

        # materialize with different modi
        for walled in [False] + [True] * (cObj.nDim == 3):
            for useOpti in [False, True]:
                fResObj = FemObject('data/%s.frc'%objName, True)
                c0 = fResObj.computeCompliance(complianceOnly = True)
                if useOpti:
                    weights = None if objName != 'spot2D' else icdf(fResObj.vmStress)**2 # experimental
                    fResObj.materializeOpti(alpha, walled, weights = weights)
                else:
                    fResObj.materialize(alpha, walled)
                c1 = fResObj.computeCompliance(complianceOnly = True)
                SJs = fResObj.evalScaledJacobians(False)
                mTag = 'w' if walled else 'b'
                res.append([objName, fResObj.mTypeInit + '_' + mTag, useOpti, fResObj.nVerts, fResObj.nElems, fResObj.vol / fResObj.volInit, c1 / c0, SJs.mean(), SJs.min()])

    with open(logDir + 'examples.log', 'w') as fh:
        ln = ', '.join(['% 9s'%s for s in res[0]])
        print(ln)
        fh.write(ln+'\n')
        for r in res[1:]:
            method = ('tau' + '*' * r[2]) if r[2] is not None else ''
            ln = ', '.join(['% 9s'%s for s in [r[0], r[1], method]])
            ln += ', ' + ', '.join(['% 9d'%d for d in [r[3],r[4]]])
            ln += ', ' + ', '.join(['% 0.6f'%f for f in r[5:]])
            print(ln)
            fh.write(ln+'\n')

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API