| 1 | /*
|
|---|
| 2 | * \file Loads.c
|
|---|
| 3 | * \brief: implementation of the Loads class, derived from DataSet class
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*Headers: {{{1*/
|
|---|
| 7 | #ifdef HAVE_CONFIG_H
|
|---|
| 8 | #include "config.h"
|
|---|
| 9 | #else
|
|---|
| 10 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| 13 | #include <vector>
|
|---|
| 14 | #include <functional>
|
|---|
| 15 | #include <algorithm>
|
|---|
| 16 | #include <iostream>
|
|---|
| 17 |
|
|---|
| 18 | #include "./DataSet.h"
|
|---|
| 19 | #include "../shared/shared.h"
|
|---|
| 20 | #include "../include/include.h"
|
|---|
| 21 | #include "../EnumDefinitions/EnumDefinitions.h"
|
|---|
| 22 |
|
|---|
| 23 | using namespace std;
|
|---|
| 24 | /*}}}*/
|
|---|
| 25 |
|
|---|
| 26 | /*Object constructors and destructor*/
|
|---|
| 27 | /*FUNCTION Loads::Loads(){{{1*/
|
|---|
| 28 | Loads::Loads(){
|
|---|
| 29 | return;
|
|---|
| 30 | }
|
|---|
| 31 | /*}}}*/
|
|---|
| 32 | /*FUNCTION Loads::Loads(int in_enum){{{1*/
|
|---|
| 33 | Loads::Loads(int in_enum): DataSet(in_enum){
|
|---|
| 34 | //do nothing;
|
|---|
| 35 | return;
|
|---|
| 36 | }
|
|---|
| 37 | /*}}}*/
|
|---|
| 38 | /*FUNCTION Loads::~Loads(){{{1*/
|
|---|
| 39 | Loads::~Loads(){
|
|---|
| 40 | return;
|
|---|
| 41 | }
|
|---|
| 42 | /*}}}*/
|
|---|
| 43 |
|
|---|
| 44 | /*Numerics:*/
|
|---|
| 45 | /*FUNCTION Loads::MeltingIsPresent{{{1*/
|
|---|
| 46 | int Loads::MeltingIsPresent(){
|
|---|
| 47 |
|
|---|
| 48 | int i;
|
|---|
| 49 | int found=0;
|
|---|
| 50 | int mpi_found=0;
|
|---|
| 51 |
|
|---|
| 52 | for(i=0;i<this->Size();i++){
|
|---|
| 53 | Object* object=(Object*)this->GetObjectByOffset(i);
|
|---|
| 54 | if (object->Enum()==PengridEnum){
|
|---|
| 55 | found=1;
|
|---|
| 56 | break;
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | #ifdef _PARALLEL_
|
|---|
| 61 | MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
|
|---|
| 62 | MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);
|
|---|
| 63 | found=mpi_found;
|
|---|
| 64 | #endif
|
|---|
| 65 |
|
|---|
| 66 | return found;
|
|---|
| 67 | }
|
|---|
| 68 | /*}}}*/
|
|---|
| 69 | /*FUNCTION Loads::MeltingConstraints{{{1*/
|
|---|
| 70 | void Loads::MeltingConstraints(int* pconverged, int* pnum_unstable_constraints){
|
|---|
| 71 |
|
|---|
| 72 | int i;
|
|---|
| 73 |
|
|---|
| 74 | int unstable=0;
|
|---|
| 75 | int num_unstable_constraints=0;
|
|---|
| 76 | int converged=0;
|
|---|
| 77 | int sum_num_unstable_constraints=0;
|
|---|
| 78 |
|
|---|
| 79 | num_unstable_constraints=0;
|
|---|
| 80 |
|
|---|
| 81 | /*Enforce constraints: */
|
|---|
| 82 | for(i=0;i<this->Size();i++){
|
|---|
| 83 | Object* object=(Object*)this->GetObjectByOffset(i);
|
|---|
| 84 | if(object->Enum()==PengridEnum){
|
|---|
| 85 |
|
|---|
| 86 | Pengrid* pengrid=(Pengrid*)object;
|
|---|
| 87 | pengrid->PenaltyConstrain(&unstable);
|
|---|
| 88 | num_unstable_constraints+=unstable;
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | #ifdef _PARALLEL_
|
|---|
| 93 | MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
|
|---|
| 94 | MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);
|
|---|
| 95 | num_unstable_constraints=sum_num_unstable_constraints;
|
|---|
| 96 | #endif
|
|---|
| 97 |
|
|---|
| 98 | /*Have we converged? : */
|
|---|
| 99 | if (num_unstable_constraints==0) converged=1;
|
|---|
| 100 | else converged=0;
|
|---|
| 101 |
|
|---|
| 102 | /*Assign output pointers: */
|
|---|
| 103 | *pconverged=converged;
|
|---|
| 104 | *pnum_unstable_constraints=num_unstable_constraints;
|
|---|
| 105 | }
|
|---|
| 106 | /*}}}*/
|
|---|