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/mit-gfx/diff_stokes_flow
12 November 2025, 16:13:46 UTC
  • Code
  • Branches (2)
  • Releases (1)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/develop
    • refs/heads/master
    • v1.0
  • 1b30001
  • /
  • cpp
  • /
  • core
  • /
  • src
  • /
  • shape
  • /
  • parametric_shape.cpp
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:71ed3139f0e0334d2dd01fb1252ca5bd4adc2f17
origin badgedirectory badge Iframe embedding
swh:1:dir:ba254e4a3e6ede3ec9819e506cadd1e9141eb296
origin badgerevision badge
swh:1:rev:55eb7c0f3a9d58a50c1a09c2231177b81e0da84e
origin badgesnapshot badge
swh:1:snp:844e2388a41ac424d434588931efb89dd8b339bf

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: 55eb7c0f3a9d58a50c1a09c2231177b81e0da84e authored by Tao Du on 11 December 2020, 03:55:44 UTC
Create LICENSE
Tip revision: 55eb7c0
parametric_shape.cpp
#include "shape/parametric_shape.h"
#include "common/common.h"

template<int dim>
ParametricShape<dim>::ParametricShape() : param_num_(0) {
    cell_num_prod_ = 1;
    node_num_prod_ = 1;
    for (int i = 0; i < dim; ++i) {
        cell_nums_[i] = 1;
        cell_num_prod_ *= cell_nums_[i];
        node_nums_[i] = cell_nums_[i] + 1;
        node_num_prod_ *= node_nums_[i];
    }
    signed_distances_ = std::vector<real>(node_num_prod_, 0);
    signed_distance_gradients_ = std::vector<std::vector<real>>(node_num_prod_, std::vector<real>(param_num_, 0));
    params_ = std::vector<real>();
}

template<int dim>
void ParametricShape<dim>::Initialize(const std::array<int, dim>& cell_nums, const std::vector<real>& params,
    const bool compute_signed_distance_and_grad) {
    cell_nums_ = cell_nums;
    cell_num_prod_ = 1;
    node_num_prod_ = 1;
    for (int i = 0; i < dim; ++i) {
        cell_num_prod_ *= cell_nums_[i];
        node_nums_[i] = cell_nums_[i] + 1;
        node_num_prod_ *= node_nums_[i];
    }
    params_ = params;
    param_num_ = static_cast<int>(params.size());

    InitializeCustomizedData();

    // Now compute the gradients.
    signed_distances_.resize(node_num_prod_);
    signed_distance_gradients_.resize(node_num_prod_);
    for (int i = 0; i < node_num_prod_; ++i) signed_distance_gradients_[i].resize(param_num_);

    if (compute_signed_distance_and_grad) {
        #pragma omp parallel for
        for (int i = 0; i < node_num_prod_; ++i) {
            const auto idx = GetIndex(i, node_nums_);
            // Cast to real.
            std::array<real, dim> p;
            for (int j = 0; j < dim; ++j) p[j] = static_cast<real>(idx[j]);
            signed_distances_[i] = ComputeSignedDistanceAndGradients(p, signed_distance_gradients_[i]);
        }
    }
}

template<int dim>
const int ParametricShape<dim>::cell_num(const int i) const {
    CheckError(0 <= i && i < dim, "Dimension out of bound.");
    return cell_nums_[i];
}

template<int dim>
const int ParametricShape<dim>::node_num(const int i) const {
    CheckError(0 <= i && i < dim, "Dimension out of bound.");
    return node_nums_[i];
}

template<int dim>
const real ParametricShape<dim>::signed_distance(const std::array<int, dim>& node_idx) const {
    return signed_distances_[GetIndex(node_idx, node_nums_)];
}

template<int dim>
const std::vector<real>& ParametricShape<dim>::signed_distance_gradients(
    const std::array<int, dim>& node_idx) const {
    return signed_distance_gradients_[GetIndex(node_idx, node_nums_)];
}

template class ParametricShape<2>;
template class ParametricShape<3>;

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