コード例 #1
0
TEST_F(ModelFixture, ConstructionWithInternalSource_ReverseConstructionWithInternalSource_2)
{
  Model model;

  // Create some materials
  StandardOpaqueMaterial exterior(model);
  StandardOpaqueMaterial interior(model);

  OpaqueMaterialVector layers;
  layers.push_back(exterior);
  layers.push_back(interior);

  ConstructionWithInternalSource construction(layers);

  EXPECT_EQ(1u, model.getModelObjects<ConstructionWithInternalSource>().size());

  ConstructionWithInternalSource construction2 = construction.reverseConstructionWithInternalSource();

  EXPECT_EQ(2u, model.getModelObjects<ConstructionWithInternalSource>().size());
  EXPECT_NE(construction.handle(), construction2.handle());

  MaterialVector testLayers = construction2.layers();
  ASSERT_EQ(static_cast<unsigned>(2),testLayers.size());
  EXPECT_TRUE(testLayers[0] == interior);
  EXPECT_TRUE(testLayers[1] == exterior);

  ConstructionWithInternalSource construction3 = construction.reverseConstructionWithInternalSource();
  EXPECT_EQ(2u, model.getModelObjects<ConstructionWithInternalSource>().size());
  EXPECT_NE(construction.handle(), construction3.handle());
  EXPECT_EQ(construction2.handle(), construction3.handle());
}
コード例 #2
0
  bool LayeredConstruction_Impl::insertLayer(unsigned layerIndex, 
                                             const Material& material) 
  {
    OS_ASSERT(material.model() == model());
    layerIndex = mf_clearNullLayers(layerIndex);

    unsigned n = numLayers();
    MaterialVector layers = this->layers();
    MaterialVector::iterator layersBegin = layers.begin();
    MaterialVector::iterator layersEnd = layers.end();
    MaterialVector::iterator insertAtIt = layersBegin;
    while ((static_cast<unsigned>(insertAtIt - layersBegin) < layerIndex) &&
           (insertAtIt != layersEnd)) 
    { ++insertAtIt; }
    layers.insert(insertAtIt, material);
    OS_ASSERT(layers.size() == ++n);
    if ((model().strictnessLevel() < StrictnessLevel::Final) || 
        LayeredConstruction::layersAreValid(layers)) 
    {
      IdfExtensibleGroup idfGroup = insertExtensibleGroup(layerIndex,StringVector());
      OS_ASSERT(!idfGroup.empty());
      ModelExtensibleGroup group = idfGroup.cast<ModelExtensibleGroup>();
      bool ok = group.setPointer(0,material.handle());
      OS_ASSERT(ok);
      return true;
    }

    return false;
  }
コード例 #3
0
TEST_F(ModelFixture, Construction_Layers)
{
  Model model;

  // Create some materials
  StandardOpaqueMaterial exterior(model);
  AirGap air(model);
  StandardOpaqueMaterial interior(model);

  OpaqueMaterialVector layers;
  layers.push_back(exterior);
  layers.push_back(air);
  layers.push_back(interior);

  Construction construction(layers);

  // Get layers
  MaterialVector testLayers = construction.layers();
  ASSERT_EQ(static_cast<unsigned>(3),testLayers.size());
  EXPECT_TRUE(testLayers[0] == exterior);
  EXPECT_TRUE(testLayers[1] == air);
  EXPECT_TRUE(testLayers[2] == interior);

  // construct by clone
  Model modelClone = model.clone().cast<Model>();
  EXPECT_EQ(static_cast<unsigned>(4),modelClone.objects().size());
  ConstructionVector constructions = modelClone.getModelObjects<Construction>();
  ASSERT_EQ(static_cast<unsigned>(1),constructions.size());
  construction = constructions[0];
  EXPECT_FALSE(construction.model() == model);
  EXPECT_TRUE(construction.iddObject().type() ==
              IddObjectType::OS_Construction);
}
コード例 #4
0
TEST_F(ModelFixture, Construction_InsertLayers)
{
  Model model;

  // Create some materials
  StandardOpaqueMaterial exterior(model);
  AirGap air(model);
  StandardOpaqueMaterial interior(model);

  Construction construction(model);
  try{
    // these functions should not throw, just return false
    EXPECT_TRUE(construction.insertLayer(0, exterior));
    EXPECT_TRUE(construction.insertLayer(1, air));
    EXPECT_TRUE(construction.insertLayer(2, interior));
  }catch(const std::exception&){
    
  }

  // Get layers
  MaterialVector testLayers = construction.layers();
  ASSERT_EQ(static_cast<unsigned>(3),testLayers.size());
  EXPECT_TRUE(testLayers[0] == exterior);
  EXPECT_TRUE(testLayers[1] == air);
  EXPECT_TRUE(testLayers[2] == interior);
}
コード例 #5
0
boost::optional<IdfObject> ForwardTranslator::translateConstruction( Construction & modelObject )
{
  IdfObject construction( openstudio::IddObjectType::Construction );
  m_idfObjects.push_back(construction);

  for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()){
    translateAndMapModelObject(lifeCycleCost);
  }

  construction.setName(modelObject.name().get());

  MaterialVector layers = modelObject.layers();

  unsigned fieldIndex = 1;
  for(unsigned layerIndex = 0; layerIndex < layers.size(); ++layerIndex ) {
    Material material = layers[layerIndex];
    translateAndMapModelObject(material);
    construction.setString(fieldIndex++, material.name().get());
  }

  return boost::optional<IdfObject>(construction);
}
コード例 #6
0
TEST_F(ModelFixture, ConstructionWithInternalSource_Layers)
{
  Model model;

  // Create some materials
  StandardOpaqueMaterial exterior(model);
  AirGap air(model);
  StandardOpaqueMaterial interior(model);

  MaterialVector layers;
  layers.push_back(exterior);
  layers.push_back(air);
  layers.push_back(interior);

  ConstructionWithInternalSource construction(model);
  EXPECT_TRUE(construction.setLayers(layers));

  // Get layers
  MaterialVector testLayers = construction.layers();
  ASSERT_EQ(static_cast<unsigned>(3),testLayers.size());
  EXPECT_TRUE(testLayers[0] == exterior);
  EXPECT_TRUE(testLayers[1] == air);
  EXPECT_TRUE(testLayers[2] == interior);
}
コード例 #7
0
ファイル: Material_GTest.cpp プロジェクト: NREL/OpenStudio
TEST_F(ModelFixture, Material)
{
  Model model;

  StandardOpaqueMaterial exterior(model);

  MaterialVector materials = model.getModelObjects<Material>();
  ASSERT_EQ(static_cast<unsigned>(1), materials.size());

  StandardsInformationMaterialVector materialInformations = model.getModelObjects<StandardsInformationMaterial>();
  ASSERT_EQ(static_cast<unsigned>(0), materialInformations.size());

  {
    Model testModel;

    exterior.clone(testModel);

    materials = model.getModelObjects<Material>();
    ASSERT_EQ(static_cast<unsigned>(1), materials.size());

    materialInformations = model.getModelObjects<StandardsInformationMaterial>();
    ASSERT_EQ(static_cast<unsigned>(0), materialInformations.size());

    materials = testModel.getModelObjects<Material>();
    ASSERT_EQ(static_cast<unsigned>(1), materials.size());

    materialInformations = testModel.getModelObjects<StandardsInformationMaterial>();
    ASSERT_EQ(static_cast<unsigned>(0), materialInformations.size());
  }

  StandardsInformationMaterial info = exterior.standardsInformation();

  {
    Model testModel;

    exterior.clone(testModel);


    materials = model.getModelObjects<Material>();
    ASSERT_EQ(static_cast<unsigned>(1), materials.size());

    materialInformations = model.getModelObjects<StandardsInformationMaterial>();
    ASSERT_EQ(static_cast<unsigned>(1), materialInformations.size());

    materials = testModel.getModelObjects<Material>();
    ASSERT_EQ(static_cast<unsigned>(1), materials.size());

    materialInformations = testModel.getModelObjects<StandardsInformationMaterial>();
    ASSERT_EQ(static_cast<unsigned>(1), materialInformations.size());
  }

  {
    Model testModel;

    info.clone(testModel);

    materials = model.getModelObjects<Material>();
    ASSERT_EQ(static_cast<unsigned>(1), materials.size());

    materialInformations = model.getModelObjects<StandardsInformationMaterial>();
    ASSERT_EQ(static_cast<unsigned>(1), materialInformations.size());

    materials = testModel.getModelObjects<Material>();
    ASSERT_EQ(static_cast<unsigned>(0), materials.size());

    materialInformations = testModel.getModelObjects<StandardsInformationMaterial>();
    ASSERT_EQ(static_cast<unsigned>(1), materialInformations.size());
  }

  StandardOpaqueMaterial exteriorClone = exterior.clone().cast<StandardOpaqueMaterial>();

  materials = model.getModelObjects<Material>();
  ASSERT_EQ(static_cast<unsigned>(2), materials.size());

  materialInformations = model.getModelObjects<StandardsInformationMaterial>();
  ASSERT_EQ(static_cast<unsigned>(2), materialInformations.size());

}
コード例 #8
0
  ConstructionWithInternalSource ConstructionWithInternalSource_Impl::reverseConstructionWithInternalSource() const
  {
    MaterialVector reverseLayers(this->layers());
    std::reverse(reverseLayers.begin(), reverseLayers.end());

    int numLayers = (int)this->numLayers();
    int reverseSourcePresentAfterLayerNumber = numLayers - this->sourcePresentAfterLayerNumber();
    int reverseTemperatureCalculationRequestedAfterLayerNumber = numLayers - this->temperatureCalculationRequestedAfterLayerNumber();
    int dimensionsForTheCTFCalculation = this->dimensionsForTheCTFCalculation();
    double tubeSpacing = this->tubeSpacing();

    Model model = this->model();
    for (const ConstructionWithInternalSource& other : model.getConcreteModelObjects<ConstructionWithInternalSource>()) {
      
      if (other.sourcePresentAfterLayerNumber() != reverseSourcePresentAfterLayerNumber){
        continue;
      }

      if (other.temperatureCalculationRequestedAfterLayerNumber() != reverseTemperatureCalculationRequestedAfterLayerNumber){
        continue;
      }

      if (other.dimensionsForTheCTFCalculation() != dimensionsForTheCTFCalculation){
        continue;
      }

      if (other.tubeSpacing() != tubeSpacing){
        continue;
      }

      MaterialVector layers = other.layers();
      if (layers.size() != reverseLayers.size()){
        continue;
      }

      bool test = true;
      for (unsigned i = 0; i < layers.size(); ++i){
        if (layers[i].handle() != reverseLayers[i].handle()){
          test = false;
          break; // break out of loop over layers
        }
      }

      if (test){
        return other;
      }
    }

    // TODO: this should also copy (and modify) standards information object

    // no match, make one
    ConstructionWithInternalSource result(model);
    result.setName(this->name().get() + " Reversed");
    result.setSourcePresentAfterLayerNumber(reverseSourcePresentAfterLayerNumber);
    result.setTemperatureCalculationRequestedAfterLayerNumber(reverseTemperatureCalculationRequestedAfterLayerNumber);
    result.setDimensionsForTheCTFCalculation(dimensionsForTheCTFCalculation);
    result.setTubeSpacing(tubeSpacing);
    result.setLayers(reverseLayers);

    return result;
  }
コード例 #9
0
TEST_F(ModelFixture, ConstructionWithInternalSource_FromLayers)
{
  Model model;

  // Create some materials
  StandardOpaqueMaterial exterior(model);
  StandardOpaqueMaterial interior(model);

  OpaqueMaterialVector layers;

  EXPECT_EQ(0, model.getModelObjects<ConstructionWithInternalSource>().size());

  EXPECT_EQ(0, layers.size());
  EXPECT_THROW((ConstructionWithInternalSource(layers)), std::exception);

  EXPECT_EQ(0, model.getModelObjects<ConstructionWithInternalSource>().size());

  layers.push_back(exterior);

  EXPECT_EQ(1u, layers.size());
  EXPECT_THROW((ConstructionWithInternalSource(layers)), std::exception);

  EXPECT_EQ(0, model.getModelObjects<ConstructionWithInternalSource>().size());

  layers.push_back(interior);

  EXPECT_EQ(2u, layers.size());
  ConstructionWithInternalSource construction(layers);
  EXPECT_EQ(2u, construction.numLayers());
  EXPECT_EQ(2u, construction.layers().size());
  EXPECT_EQ(1, construction.sourcePresentAfterLayerNumber());
  EXPECT_EQ(1, construction.temperatureCalculationRequestedAfterLayerNumber());
  EXPECT_EQ(1, construction.dimensionsForTheCTFCalculation());
  EXPECT_EQ(0.154, construction.tubeSpacing());

  // check that we can't mess up the construction
  EXPECT_FALSE(construction.setSourcePresentAfterLayerNumber(3));
  EXPECT_EQ(1, construction.sourcePresentAfterLayerNumber());
  EXPECT_FALSE(construction.setTemperatureCalculationRequestedAfterLayerNumber(3));
  EXPECT_EQ(1, construction.temperatureCalculationRequestedAfterLayerNumber());

  EXPECT_TRUE(construction.eraseLayer(1));
  EXPECT_EQ(1u, construction.numLayers());

  EXPECT_FALSE(construction.setLayers(MaterialVector()));
  EXPECT_EQ(1u, construction.numLayers());

  MaterialVector testLayers = construction.layers();
  ASSERT_EQ(static_cast<unsigned>(1),testLayers.size());
  EXPECT_TRUE(testLayers[0] == exterior);

  testLayers.push_back(interior);
  testLayers.push_back(exterior);

  EXPECT_TRUE(construction.setLayers(testLayers));
  EXPECT_EQ(3u, construction.numLayers());

  testLayers = construction.layers();
  ASSERT_EQ(static_cast<unsigned>(3),testLayers.size());
  EXPECT_TRUE(testLayers[0] == exterior);
  EXPECT_TRUE(testLayers[1] == interior);
  EXPECT_TRUE(testLayers[2] == exterior);

  EXPECT_TRUE(construction.setSourcePresentAfterLayerNumber(3));
  EXPECT_EQ(3, construction.sourcePresentAfterLayerNumber());
  EXPECT_TRUE(construction.setTemperatureCalculationRequestedAfterLayerNumber(3));
  EXPECT_EQ(3, construction.temperatureCalculationRequestedAfterLayerNumber());

  testLayers.clear();
  testLayers.push_back(interior);
  testLayers.push_back(exterior);

  EXPECT_TRUE(construction.setLayers(testLayers));
  EXPECT_EQ(2u, construction.numLayers());

  testLayers = construction.layers();
  ASSERT_EQ(static_cast<unsigned>(2),testLayers.size());
  EXPECT_TRUE(testLayers[0] == interior);
  EXPECT_TRUE(testLayers[1] == exterior);

  EXPECT_EQ(1, construction.sourcePresentAfterLayerNumber());
  EXPECT_EQ(1, construction.temperatureCalculationRequestedAfterLayerNumber());

  EXPECT_FALSE(construction.setSourcePresentAfterLayerNumber(3));
  EXPECT_EQ(1, construction.sourcePresentAfterLayerNumber());
  EXPECT_FALSE(construction.setTemperatureCalculationRequestedAfterLayerNumber(3));
  EXPECT_EQ(1, construction.temperatureCalculationRequestedAfterLayerNumber());

  while (layers.size() < 11) {
    layers.push_back(exterior);
  }
  EXPECT_THROW((ConstructionWithInternalSource(layers)), std::exception);
}